N-sim
Emulation and simulation of
Wireless Sensor Networks



   Home


   Project Page


   Download


   CVS



   Installation


   Configuration


   Plug-ins




 Hosted by
SourceForge.net Logo

/home/brennan/n-sim/OrbisQuartus/control/partition.cpp

Go to the documentation of this file.
00001 
00014 /*
00015  * Copyright 2007. Los Alamos National Security, LLC. This material
00016  * was produced under U.S. Government contract DE-AC52-06NA25396 for
00017  * Los Alamos National Laboratory (LANL), which is operated by Los
00018  * Alamos National Security, LLC, for the Department of Energy. The
00019  * U.S. Government has rights to use, reproduce, and distribute this
00020  * software. NEITHER THE GOVERNMENT NOR LOS ALAMOS NATIONAL SECURITY,
00021  * LLC, MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR ASSUMES ANY LEGAL
00022  * LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified to
00023  * produce derivative works, such modified software should be clearly
00024  * marked, so as not to confuse it with the version available from LANL.
00025  *
00026  * Additionally, this program is free software; you can redistribute
00027  * it and/or modify it under the terms of the GNU General Public
00028  * License as published by the Free Software Foundation; version 2 of
00029  * the License. Accordingly, this program is distributed in the hope
00030  * it will be useful, but WITHOUT ANY WARRANTY; without even the
00031  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00032  * PURPOSE. See the GNU General Public License for more details.
00033  */
00034 
00035 
00036 #include <stdio.h>
00037 #include "partition.h"
00038 
00039 
00040 Partition::Partition(unsigned int s)
00041 {
00042         unsigned int i;
00043         _size = s;
00044         _arr = new Partition_Element[s];
00045 
00046         for (i = 0; i < s; i++) {
00047                 _arr[i].size = 0;
00048                 _arr[i].head = _arr[i].tail = 0;
00049         }
00050 }
00051 
00052 
00053 Partition::~Partition()
00054 {
00055         unsigned int i;
00056         for (i = 0; i < _size; i++) {
00057                 Partition_Node *head = _arr[i].head;
00058                 while (head != 0) {
00059                         Partition_Node *tmp = head;
00060                         head = head->next;
00061                         delete tmp;
00062                 }
00063         }
00064         delete[] _arr;
00065 }
00066 
00067 
00068 void Partition::print()
00069 {
00070         unsigned int i;
00071         for (i = 0; i < _size; i++) {
00072             Partition_Node *vertex = _arr[i].head;
00073 
00074             if (vertex == 0)
00075                     continue;
00076 
00077             printf(" [%d] -> ", i);
00078             while (vertex != 0) {
00079                     printf("%d", vertex->id);
00080                     if (vertex->next != 0)
00081                             printf(", ");
00082                     vertex = vertex->next;
00083             }
00084             printf("\n");
00085         }
00086 }


© 2007, Los Alamos National Security, LLC.