MultiLL.h

00001 /*  _________________________________________________________________________
00002  *
00003  *  UTILIB: A utility library for developing portable C++ codes.
00004  *  Copyright (c) 2001, Sandia National Laboratories.
00005  *  This software is distributed under the GNU Lesser General Public License.
00006  *  For more information, see the README file in the top UTILIB directory.
00007  *  _________________________________________________________________________
00008  */
00009 
00010 //
00011 // MLL.h
00012 //
00013 //
00014 
00015 #ifndef __MultiLL_h
00016 #define __MultiLL_h
00017 
00018 #ifdef __GNUC__
00019 #pragma interface
00020 #endif
00021 
00022 #include "IntVector.h"
00023 #include "Uniform.h"
00024 
00025 
00026 //=========================================================================
00027 // MLL.h - Class for static implementation of multiple linked lists
00028 //             within shared data structure 
00029 //=========================================================================
00030 // PRELIMINARY DESCRIPTION:
00031 // This class is meant to provide a single set of structures that supports
00032 // the management of multiple linked lists that are dynamic in length.  
00033 // Housekeeping methods keep the structures from growing too sparse, and 
00034 // users may choose the level of housekeeping enforced in the structures
00035 
00036 
00037 class UTILIB_API MultiLL
00038 {
00039  public:
00040 
00041     MultiLL();
00042 
00043     ~MultiLL();
00044 
00045     // returns 1 if the value sought is found in the 
00046     // chain referenced, returns 0 otherwise
00047     int find_value(int type_id,int value);
00048 
00049     // inserts a new value into available slot in
00050     // the value table and manages chains
00051     int insert(int type_id, int value,int expiration);
00052 
00053 
00054     void remove_index(int type_id, int remove_index);
00055 
00056 
00057     // finds value in table, removes, manages chain
00058     int remove_value(int type_id,int value);
00059 
00060     void show_list(int maxtype);
00061 
00062     int sublist_empty(int type_id);
00063 
00064     void resize();
00065 
00066     void set_up(int number_of_types,int number_of_entries_per);
00067 
00069     void clean_up(int current_iteration);
00070 
00071 
00072 
00073  protected:
00074 
00075     int MAXTYPES;
00076     int MAXTABLESIZE;
00077 
00078     IntVector First;     // holds the index of the first entry 
00079                          // in table for each type 
00080 
00081     IntVector Last;      // holds the index of the first entry 
00082                          // in table for each type
00083 
00084 
00085     // provide doubly linked chaining                
00086     IntVector Next; 
00087     IntVector Prev;
00088 
00089     IntVector table;     // represents the table of entries
00090     IntVector timestamp; // holds expiration for each local tabu table entry
00091 
00092     IntVector Reserved; // 0/1 for whether a table slot is reserved
00093                         // for the next entry of some type
00094 
00095     // returns the table index of the earliest free spot in table
00096     int next_free();
00097 
00098     // contains a value in a chain.
00099     IntVector Value_Table; 
00100 
00101     // time Value entry made
00102     IntVector TimeStamp; 
00103 
00104 };
00105 
00106 #endif
00107 
00108 
00109 
00110