00001 #include "LinkedBlockList.h" 00002 #include <stdio.h> 00003 #include <stdlib.h> 00004 00005 /*********************************************************************/ 00006 00007 void LinkedBlockList::addFront(ListType item) { 00008 00009 if ( m_head_block_size == GCLL_BLOCK_SIZE ) 00010 { 00011 LLBlock *tmp = (LLBlock *) new LLBlock; 00012 if ( !tmp ) {printf("\nOut of memory");exit(1);} 00013 tmp -> m_next = m_head; 00014 m_head = tmp; 00015 m_head_block_size = 0; 00016 } 00017 00018 m_head ->m_item[m_head_block_size] = item; 00019 m_head_block_size++; 00020 } 00021 00022 /*********************************************************************/ 00023 00024 ListType LinkedBlockList::next() 00025 { 00026 ListType toReturn = m_cursor -> m_item[m_cursor_ind]; 00027 00028 m_cursor_ind++; 00029 00030 if ( m_cursor == m_head && m_cursor_ind >= m_head_block_size ) 00031 { 00032 m_cursor = m_cursor ->m_next; 00033 m_cursor_ind = 0; 00034 } 00035 else if ( m_cursor_ind == GCLL_BLOCK_SIZE ) 00036 { 00037 m_cursor = m_cursor ->m_next; 00038 m_cursor_ind = 0; 00039 } 00040 return(toReturn); 00041 } 00042 00043 /*********************************************************************/ 00044 00045 bool LinkedBlockList::hasNext() 00046 { 00047 if ( m_cursor != 0 ) return (true); 00048 else return(false); 00049 } 00050 00051 00052 /*********************************************************************/ 00053 00054 LinkedBlockList::~LinkedBlockList() 00055 { 00056 LLBlock *tmp; 00057 00058 while ( m_head != 0 ) 00059 { 00060 tmp = m_head; 00061 m_head = m_head->m_next; 00062 delete tmp; 00063 } 00064 }; 00065 00066 /*********************************************************************/ 00067