ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/gclib/gclib/GList.hh
(Generate patch)
# Line 163 | Line 163
163      void deallocate_item(OBJ* item); //forcefully call fFreeProc or delete on item
164      void Clear();
165      void Exchange(int idx1, int idx2);
166 +    void Swap(int idx1, int idx2)  { Exchange(idx1, idx2); }
167      OBJ* First() { return (fCount>0)?fList[0]:NULL; }
168      OBJ* Last()  { return (fCount>0)?fList[fCount-1]:NULL;}
169      bool isEmpty() { return fCount==0; }
# Line 654 | Line 655
655   fArray[idx]=item;
656   }
657  
658 + template <class OBJ> void GVec<OBJ>::Exchange(int idx1, int idx2) {
659 + TEST_INDEX(idx1);
660 + TEST_INDEX(idx2);
661 + OBJ item=fArray[idx1];
662 + fArray[idx1]=fArray[idx2];
663 + fArray[idx2]=item;
664 + }
665 +
666 +
667   template <class OBJ> void GArray<OBJ>::Replace(int idx, OBJ& item) {
668   //TEST_INDEX(idx);
669   if (idx<0 || idx>=this->fCount) GError(SLISTINDEX_ERR, __FILE__,__LINE__, idx);
# Line 905 | Line 915
915   }
916  
917   template <class OBJ> void GPVec<OBJ>::Exchange(int idx1, int idx2) {
918 < //BE_UNSORTED; //cannot do that in a sorted list!
918 > //Warning: this will BREAK sort order for sorted GList
919   TEST_INDEX(idx1);
920   TEST_INDEX(idx2);
921   OBJ* item=fList[idx1];
# Line 1211 | Line 1221
1221  
1222   template <class OBJ> void GList<OBJ>::Put(int idx, OBJ* item, bool re_sort) {
1223   //WARNING: this will never free the replaced item!
1224 + // this may BREAK the sort order unless the "re_sort" parameter is given
1225   if (idx<0 || idx>this->fCount) GError(SLISTINDEX_ERR, idx);
1226   this->fList[idx]=item;
1227   if (SORTED && item!=NULL && re_sort) Sort(); //re-sort

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines