LinkedBlockList.h
Go to the documentation of this file.
00001 /* Singly Linked List of Blocks */
00002 // This data structure should be used only for the GCoptimization class implementation
00003 // because it lucks some important general functions for general list, like remove_item()
00004 // The head block may be not full 
00005 // For regular 2D grids, it's better to set GCLL_BLOCK_SIZE to 2
00006 // For other graphs, it should be set to the average expected number of neighbors
00007 // Data in linked list for the neighborhood system is allocated in blocks of size GCLL_BLOCK_SIZE 
00008 
00009 #ifndef __LINKEDBLOCKLIST_H__
00010 #define __LINKEDBLOCKLIST_H__
00011 
00012 #define GCLL_BLOCK_SIZE 4  
00013 // GCLL_BLOCKSIZE should "fit" into the type BlockType. That is 
00014 // if GCLL_BLOCKSIZE is larger than 255 but smaller than largest short integer
00015 // then  BlockType should be set to short
00016 typedef char BlockType;
00017 
00018 //The type of data stored in the linked list
00019 typedef void * ListType;
00020 
00021 class LinkedBlockList{
00022 
00023 public: 
00024         void addFront(ListType item);
00025         inline bool isEmpty(){if (m_head == 0) return(true); else return(false);};
00026         inline LinkedBlockList(){m_head = 0; m_head_block_size = GCLL_BLOCK_SIZE;}; 
00027         ~LinkedBlockList();
00028 
00029         // Next three functins are for the linked list traversal
00030         inline void setCursorFront(){m_cursor = m_head; m_cursor_ind = 0;};
00031         ListType next();
00032         bool hasNext();
00033 
00034 private:
00035         typedef struct LLBlockStruct{
00036                 ListType m_item[GCLL_BLOCK_SIZE];
00037                 struct LLBlockStruct *m_next;
00038         } LLBlock;
00039 
00040         LLBlock *m_head;
00041         // Remembers the number of elements in the head block, since it may not be full
00042         BlockType m_head_block_size;
00043         // For block traversal, points to current element in the current block
00044         BlockType m_cursor_ind;
00045         // For block traversal, points to current block in the linked list
00046         LLBlock *m_cursor;
00047 };
00048 
00049 #endif
00050 


tabletop_pushing
Author(s): Tucker Hermans
autogenerated on Wed Nov 27 2013 11:59:44