ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/gclib/gclib/GVec.hh
(Generate patch)
# Line 82 | Line 82
82      int  Count() { return fCount; }
83  
84      void setCount(int NewCount);         // will trim or expand the array as needed
85 <    void setCount(int NewCount, OBJ& v); //same as setCount(), but if expanding, new objects are set to v
85 >    void setCount(int NewCount, OBJ& v); //same as setCount() but new objects are set to v
86      void Resize(int NewCount) { setCount(NewCount); }
87      void Resize(int NewCount, OBJ& v) { setCount(NewCount, v); }
88  
# Line 105 | Line 105
105      void Expand();
106      void Grow();
107      void Grow(int idx, OBJ* newitem);
108    void setCount(int NewCount); //will trim/expand the array as needed
108      void qSort(int L, int R, GCompareProc* cmpFunc);
109    public:  
110      static void DefaultFreeProc(pointer item) {
# Line 141 | Line 140
140      int Capacity() { return fCapacity; }
141      int Count()   { return fCount; }
142      void setCapacity(int NewCapacity);
143 +    void setCount(int NewCount); //the same as setCapacity() but the new item range is filled with NULLs
144      int Add(OBJ* item); //simply append the pointer copy
145      void Add(GPVec<OBJ>& list); //add all pointers from another list
146      void Insert(int idx, OBJ* item);
# Line 736 | Line 736
736   return -1; //not found
737   }
738  
739 < template <class OBJ> void GPVec<OBJ>::Pack()  {//also frees items!
739 > template <class OBJ> void GPVec<OBJ>::Pack()  {
740   for (int i=fCount-1; i>=0; i--)
741      if (fList[i]==NULL) Delete(i); //shift rest of fList content accordingly
742   }
# Line 745 | Line 745
745    if (NewCount<0 || NewCount > MAXLISTSIZE)
746       GError(GVEC_COUNT_ERR, NewCount);
747    if (NewCount > fCapacity) setCapacity(NewCount);
748 <  if (NewCount > fCount)
748 >  if (NewCount > fCount) //pad with NULL pointers
749      memset(fList[fCount], 0, (NewCount - fCount) * sizeof(OBJ*));
750    fCount = NewCount;
751   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines