bag.temp.c
00001
00002
00003
00004
00005
00006 #ifndef bag_T
00007 #error bag_T, the type of Bag we're manufacturing, must be defined to manufacture this template.
00008 #endif
00009
00010 #ifndef bag_count
00011
00012 #error bag_count, the maximum capacity of a bag must be defined to manufacture this template.
00013 #endif
00014
00015
00016 void ppCat(bag_label,_init)( bag_label* self )
00017 {
00018 self->m_count = 0;
00019 memset( self->m_array, 0, sizeof( self->m_array ) );
00020 }
00021
00022
00023 void ppCat(bag_label,_destroy)( bag_label* self )
00024 {
00025 m_count = 0;
00026 }
00027
00028
00029 void ppCat(bag_label,_add)( bag_label* self, bag_T* item )
00030 {
00031 if( self->m_count < bag_count )
00032 {
00033 self->m_array[self->m_count++] = item;
00034 }
00035 else
00036 {
00037
00038 }
00039 }
00040
00041
00042 void ppCat(bag_label,_remove)( bag_label* self, bag_T* item )
00043 {
00044 bag_T** search = begin();
00045 bag_T** last = search + m_count;
00046 while( search < last )
00047 {
00048 if( *search == thisOne )
00049 {
00050 *search = --*last;
00051 *last = NULL;
00052 --m_count;
00053
00054 }
00055 }
00056 }