KSquare Utilities
KKB::KKQueue< Entry > Class Template Reference

A typed container class/template that keeps track of entries via pointers only. More...

#include <KKQueue.h>

+ Inheritance diagram for KKB::KKQueue< Entry >:

Public Types

typedef std::vector< Entry * >::const_iterator const_iterator
 
typedef std::vector< Entry * >::iterator iterator
 

Public Member Functions

 KKQueue (bool _owner=true)
 
 KKQueue (const KKQueue &q, bool _owner)
 Constructor, similar to the Copy Constructor except that you can control whether it duplicates the contents. More...
 
virtual ~KKQueue ()
 Virtual destructor; if owns its contents will also call the destructor on each one entry that it contains. More...
 
virtual void Add (EntryPtr _entry)
 
virtual void AddFirst (EntryPtr _entry)
 
virtual void AddQueue (const KKQueue &q)
 Add the contents of a separate KKQueue container to this container. More...
 
EntryPtr BackOfQueue () const
 
void DeleteContents ()
 
void DeleteEntry (EntryPtr _entry)
 
void DeleteEntry (kkuint32 _idx)
 
KKQueueDuplicateListAndContents () const
 Creates a new container including duplicating the contents, which also makes the new instance the owner of those contents. More...
 
template<typename Functor >
kkuint32 FindTheKthElement (kkuint32 k, Functor pred)
 
EntryPtr FrontOfQueue () const
 
EntryPtr GetFirst () const
 
EntryPtr GetLast () const
 
EntryPtr IdxToPtr (kkuint32 idx) const
 
kkint32 LocateEntry (EntryConstPtr _entry) const
 
EntryPtr LookAtBack () const
 
EntryPtr LookAtFront () const
 
bool operator!= (const KKQueue< Entry > &rightSide) const
 returns False if NOT every entry in both containers point to the same elements More...
 
KKQueueoperator= (const KKQueue &q)
 Assignment Operator. More...
 
bool operator== (const KKQueue< Entry > &rightSide) const
 Returns True if every entry in both containers point to the same elements. More...
 
Entry & operator[] (kkuint32 i) const
 
bool Owner () const
 
void Owner (bool _owner)
 
virtual EntryPtr PopFromBack ()
 
virtual EntryPtr PopFromFront ()
 
kkint32 PtrToIdx (EntryConstPtr _entry) const
 
virtual void PushOnBack (EntryPtr _entry)
 
virtual void PushOnFront (EntryPtr _entry)
 
kkint32 QueueSize () const
 
void RandomizeOrder ()
 Randomizes the order of the vector. More...
 
void RandomizeOrder (kkint64 seed)
 
void RandomizeOrder (RandomNumGenerator &randomVariable)
 Randomizes the order of the vector. More...
 
virtual EntryPtr RemoveFirst ()
 
virtual EntryPtr RemoveLast ()
 
void SetIdxToPtr (kkuint32 _idx, Entry *_ptr)
 
void SwapIndexes (size_t idx1, size_t idx2)
 

Protected Member Functions

 KKQueue (const KKQueue &q)
 Copy Constructor creating new instance; including duplicating contents if owner set to true. More...
 

Detailed Description

template<class Entry>
class KKB::KKQueue< Entry >

A typed container class/template that keeps track of entries via pointers only.

Will act as an Array, Queue or Stack structure. Items are added by the 'PushOnFront' and 'PushOnBack' methods. They are removed by the 'PopFromFront' and 'PopFromBack' methods. What is important to keep in mind is that it holds pointers to its contents, not the actual instances. It is important to keep track who owns the objects you put in an instance of KKQueue. KKQueue has a 'Owner' flag that you can set. If it is set to 'true' then it will call the destructor on all its contents when you call KKQueue's destructor or the 'DestroyContents' method. When you add an element to a KKQueue container you can not delete it separately until you either remove it from KKQueue or delete the KKQueue container. If the KKQueue derived container owned its contents and you call its destructor then there is no need to delete the contents separately.

KKQueue is sub-classed from vector<Entry*> so you can use any method that is available for the vector<> template.

Template Parameters
EntryThe type of objects that are to be held in this container. When you add new instances of 'Entry', you need to add a pointer to it not the actual entry.

Definition at line 77 of file KKQueue.h.

Member Typedef Documentation

template<class Entry>
typedef std::vector<Entry*>::const_iterator KKB::KKQueue< Entry >::const_iterator

Definition at line 89 of file KKQueue.h.

template<class Entry>
typedef std::vector<Entry*>::iterator KKB::KKQueue< Entry >::iterator

Definition at line 88 of file KKQueue.h.

Constructor & Destructor Documentation

template<class Entry >
KKQueue::KKQueue ( bool  _owner = true)

Definition at line 219 of file KKQueue.h.

219  :
220  owner (_owner)
221  {
222  }
template<class Entry >
KKQueue::KKQueue ( const KKQueue< Entry > &  q)
protected

Copy Constructor creating new instance; including duplicating contents if owner set to true.

If the parameter 'q' owns its contents then will create new instances of its contents. That is it will call the Copy Constructor for each one of the elements it contains. If 'q' does not own its contents it will just copy over the pointers from 'q', meaning that the new instance of KKQueue will point to the same locations as 'q' does.

Definition at line 227 of file KKQueue.h.

227  :
228  owner (q.Owner ())
229 
230  {
231  //for (vector<Entry*>::const_iterator x = q.begin (); x != q.end (); x++)
232  for (const_iterator x = q.begin (); x != q.end (); x++)
233  {
234  if (owner)
235  PushOnBack (new Entry (*(*x)));
236  else
237  PushOnBack (*x);
238  }
239  }
std::vector< Entry * >::const_iterator const_iterator
Definition: KKQueue.h:89
virtual void PushOnBack(EntryPtr _entry)
Definition: KKQueue.h:398
template<class Entry >
KKQueue::KKQueue ( const KKQueue< Entry > &  q,
bool  _owner 
)

Constructor, similar to the Copy Constructor except that you can control whether it duplicates the contents.

If the '_owner' parameter is set to true then it will create new instances of the contents otherwise it will just point to the instances that already exist.

Definition at line 243 of file KKQueue.h.

245  :
246  owner (_owner)
247 
248  {
249  //for (vector<Entry*>::const_iterator x = q.begin
250  // owner (_owner) (); x != q.end (); x++)
251  for (const_iterator x = q.begin (); x != q.end (); ++x)
252  {
253  if (owner)
254  PushOnBack (new Entry (*(*x)));
255  else
256  PushOnBack (*x);
257  }
258  }
std::vector< Entry * >::const_iterator const_iterator
Definition: KKQueue.h:89
virtual void PushOnBack(EntryPtr _entry)
Definition: KKQueue.h:398
template<class Entry >
KKQueue::~KKQueue ( )
virtual

Virtual destructor; if owns its contents will also call the destructor on each one entry that it contains.

Definition at line 280 of file KKQueue.h.

281  {
282  if (owner)
283  {
284  iterator i;
285 
286  for (i = KKQueue<Entry>::begin (); i != KKQueue<Entry>::end (); i++)
287  {
288  delete *i;
289  *i = NULL;
290  }
291  }
292  } /* ~KKQueue */
std::vector< Entry * >::iterator iterator
Definition: KKQueue.h:88

Member Function Documentation

template<class Entry >
void KKQueue::Add ( EntryPtr  _entry)
inlinevirtual

same as PushOnBack

Definition at line 339 of file KKQueue.h.

340  {
341  PushOnBack (_entry);
342  }
virtual void PushOnBack(EntryPtr _entry)
Definition: KKQueue.h:398
template<class Entry >
void KKQueue::AddFirst ( EntryPtr  _entry)
inlinevirtual

same as PushOnFront

Definition at line 347 of file KKQueue.h.

348  {
349  PushOnFront (_entry);
350  }
virtual void PushOnFront(EntryPtr _entry)
Definition: KKQueue.h:383
template<class Entry >
void KKQueue::AddQueue ( const KKQueue< Entry > &  q)
virtual

Add the contents of a separate KKQueue container to this container.

Be careful how the Owner flags are set; this method adds the pointers of 'q' to the end of its own container; it does not concern itself with the state of the 'Owner' flags. If you are not careful you can have both containers thinking they own the same entries. I suggest that after you add the contents of 'q' to this container that the caller set the 'owner' flag of 'q' to false.

Definition at line 355 of file KKQueue.h.

356  {
357  for (const_iterator x = q.begin (); x != q.end (); x++)
358  PushOnBack (*x);
359  return;
360  } /* AddQueue */
std::vector< Entry * >::const_iterator const_iterator
Definition: KKQueue.h:89
virtual void PushOnBack(EntryPtr _entry)
Definition: KKQueue.h:398
template<class Entry >
KKQueue< Entry >::EntryPtr KKQueue::BackOfQueue ( ) const

Returns pointer of last element in the container without removing it. If the container is empty will return NULL.

Definition at line 661 of file KKQueue.h.

662  {
663  if (KKQueue<Entry>::size () <= 0)
664  return NULL;
665  return KKQueue<Entry>::back ();
666  }
template<class Entry >
void KKQueue::DeleteContents ( )

Empties the container, if 'owner' is set to true will call the destructor on each element.

Definition at line 321 of file KKQueue.h.

322  {
323  if (owner)
324  {
325  iterator idx;
326 
327  for (idx = KKQueue<Entry>::begin (); idx != KKQueue<Entry>::end (); idx++)
328  {
329  delete (*idx);
330  }
331  }
332 
333  KKQueue<Entry>::clear ();
334  } /* DeleteContents */
std::vector< Entry * >::iterator iterator
Definition: KKQueue.h:88
template<class Entry >
void KKQueue::DeleteEntry ( EntryPtr  _entry)

Removes from KKQueue the entry who's pointer = '_entry'

Definition at line 684 of file KKQueue.h.

685  {
686  for (iterator y = KKQueue<Entry>::begin (); y != KKQueue<Entry>::end (); y++)
687  {
688  if (*y == _entry)
689  {
690  KKQueue<Entry>::erase (y);
691  return;
692  }
693  }
694  } /* DeleteEntry */
std::vector< Entry * >::iterator iterator
Definition: KKQueue.h:88
template<class Entry >
void KKQueue::DeleteEntry ( kkuint32  _idx)

Removes from KKQueue the entry who's index = '_idx'.

Definition at line 715 of file KKQueue.h.

716  {
717  if ((kkuint32)_idx >= KKQueue<Entry>::size ())
718  return;
719 
720  iterator i = KKQueue<Entry>::begin ();
721 
722  for (kkuint32 j = 0; ((j < _idx) && (i != KKQueue<Entry>::end ())); j++)
723  i++;
724 
725  EntryPtr ep = *i;
726  KKQueue<Entry>::erase (i);
727  } /* DeleteEntry */
std::vector< Entry * >::iterator iterator
Definition: KKQueue.h:88
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
template<class Entry >
KKQueue< Entry > * KKQueue::DuplicateListAndContents ( ) const

Creates a new container including duplicating the contents, which also makes the new instance the owner of those contents.

Definition at line 263 of file KKQueue.h.

264  {
265  KKQueue<Entry>* duplicatedQueue = new KKQueue<Entry> (true, QueueSize ());
266 
267  for (const_iterator x = KKQueue<Entry>::begin (); x != KKQueue<Entry>::end (); x++)
268  {
269  const EntryPtr e = *x;
270  duplicatedQueue->PushOnBack (new Entry (*e));
271  }
272 
273  return duplicatedQueue;
274  } /* DuplicateListAndContents */
std::vector< Entry * >::const_iterator const_iterator
Definition: KKQueue.h:89
kkint32 QueueSize() const
Definition: KKQueue.h:313
template<class Entry >
template<typename Functor >
kkuint32 KKQueue::FindTheKthElement ( kkuint32  k,
Functor  pred 
)

Definition at line 527 of file KKQueue.h.

530  {
531  if ((k < 0) || (K > = (kkint32)size ()))
532  return -1;
533  return FindTheKthElement (k, 0, size () - 1, pred);
534  } /* FindTheKthElement */
kkuint32 FindTheKthElement(kkuint32 k, Functor pred)
Definition: KKQueue.h:527
__int32 kkint32
Definition: KKBaseTypes.h:88
template<class Entry >
KKQueue< Entry >::EntryPtr KKQueue::FrontOfQueue ( ) const

Returns a pointer to the element that is at from of the queue with out removing it from the queue.

Definition at line 673 of file KKQueue.h.

674  {
675  if ( KKQueue<Entry>::size () <= 0)
676  return NULL;
677 
678  return * KKQueue<Entry>::begin ();
679  }
template<class Entry >
KKQueue< Entry >::EntryPtr KKQueue::GetFirst ( ) const
inline

Same as FrontOfQueue.

Definition at line 366 of file KKQueue.h.

367  {
368  return FrontOfQueue ();
369  }
EntryPtr FrontOfQueue() const
Definition: KKQueue.h:673
template<class Entry >
KKQueue< Entry >::EntryPtr KKQueue::GetLast ( ) const
inline

Same as BackOfQueue.

Definition at line 374 of file KKQueue.h.

375  {
376  return BackOfQueue ();
377  }
EntryPtr BackOfQueue() const
Definition: KKQueue.h:661
template<class Entry >
KKQueue< Entry >::EntryPtr KKQueue::IdxToPtr ( kkuint32  idx) const

Returns back a pointer to the element who's index is 'idx'. If 'idx' is less than 0 or >= QueueSize() will return NULL.

Definition at line 732 of file KKQueue.h.

733  {
734  if (idx >= KKQueue<Entry>::size ())
735  return NULL;
736 
737  return &((*this)[idx]);
738  //return (typename Entry*)(vector<Entry*>::operator[] (idx));
739  } /* IdxToPtr */
template<class Entry >
kkint32 KKQueue::LocateEntry ( EntryConstPtr  _entry) const

Returns the index of the element who's address is '_entry'. If not found in container will return back -1.

Definition at line 745 of file KKQueue.h.

746  {
747  kkint32 i = 0;
748 
749  for (const_iterator j = KKQueue<Entry>::begin (); j != KKQueue<Entry>::end (); j++)
750  {
751  if (*j == _entry)
752  return i;
753  i++;
754  }
755  return -1;
756  } /* LocateEntry */
__int32 kkint32
Definition: KKBaseTypes.h:88
std::vector< Entry * >::const_iterator const_iterator
Definition: KKQueue.h:89
template<class Entry >
KKQueue< Entry >::EntryPtr KKQueue::LookAtBack ( ) const

Same as BackOfQueue.

Definition at line 627 of file KKQueue.h.

628  {
629  if (this->size () <= 0)
630  return NULL;
631 
632  return KKQueue<Entry>::back ();
633  }
template<class Entry >
KKQueue< Entry >::EntryPtr KKQueue::LookAtFront ( ) const

Same as FrontOfQueue.

Definition at line 638 of file KKQueue.h.

639  {
640  if (this->size () <= 0)
641  return NULL;
642  return *KKQueue<Entry>::begin ();
643  }
template<class Entry>
bool KKQueue::operator!= ( const KKQueue< Entry > &  rightSide) const

returns False if NOT every entry in both containers point to the same elements

Definition at line 457 of file KKQueue.h.

458  {
459  return !((*this) == rightSide);
460  } /* operator!= */
template<class Entry >
KKQueue< Entry > & KKQueue::operator= ( const KKQueue< Entry > &  q)

Assignment Operator.

1) Destroy's its current contents by calling 'DeleteContents'.
2) If 'q' owns its contents
create new instances of 'q's contents and add to its self then set 'owner' flag to true.
else
Copy over 'q's pointers to self and then set 'owner' flag to false.

Definition at line 415 of file KKQueue.h.

416  {
417  DeleteContents ();
418 
419  if (q.Owner ())
420  {
421  for (const_iterator x = q.begin (); x < q.end (); x++)
422  push_back (new Entry (**x));
423  this->Owner (true);
424  }
425  else
426  {
427  for (const_iterator x = q.begin (); x < q.end (); x++)
428  push_back (*x);
429  this->Owner (false);
430  }
431  return *this;
432  } /* operator= */
std::vector< Entry * >::const_iterator const_iterator
Definition: KKQueue.h:89
void DeleteContents()
Definition: KKQueue.h:321
bool Owner() const
Definition: KKQueue.h:305
template<class Entry>
bool KKQueue::operator== ( const KKQueue< Entry > &  rightSide) const

Returns True if every entry in both containers point to the same elements.

Definition at line 438 of file KKQueue.h.

439  {
440  if (QueueSize () != rightSide.QueueSize ())
441  return false;
442 
443  for (kkint32 x = 0; x < QueueSize (); x++)
444  {
445  Entry* left = IdxToPtr (x);
446  Entry* right = rightSide.IdxToPtr (x);
447  if (!((*left) == (*right)))
448  return false;
449  }
450 
451  return true;
452  } /* operator== */
__int32 kkint32
Definition: KKBaseTypes.h:88
EntryPtr IdxToPtr(kkuint32 idx) const
Definition: KKQueue.h:732
kkint32 QueueSize() const
Definition: KKQueue.h:313
template<class Entry >
Entry & KKQueue::operator[] ( kkuint32  i) const

Returns a reference to element indexed by 'i'; similar to IdxToPtr except tat it returns a reference rather than a pointer.0

Definition at line 802 of file KKQueue.h.

803  {
804  //KKQueue<Entry>::Entry* entry;
805 
806  if ((idx < 0) || (idx >= KKQueue<Entry>::size ()))
807  {
808  std::cerr << std::endl
809  << "*** ERROR *** KKQueue<Entry>::operator[], Index [" << idx << "] out of bounds." << std::endl
810  << std::endl;
811  exit (-1);
812  }
813 
814  return (Entry&)*(std::vector<Entry*>::operator[] (idx));
815  } /* operator[] */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
template<class Entry >
bool KKQueue::Owner ( ) const

Definition at line 305 of file KKQueue.h.

306  {
307  return (owner != 0);
308  }
template<class Entry >
void KKQueue::Owner ( bool  _owner)

You can specify who owns the contents of the container. '_owner' == true means when the container is deleted it will also call the destructor for each element it contains.

Definition at line 297 of file KKQueue.h.

298  {
299  owner = _owner;
300  }
template<class Entry >
KKQueue< Entry >::EntryPtr KKQueue::PopFromBack ( )
virtual

Removes the last element in the container and returns its pointer. If the container is empty will return NULL.

Reimplemented in KKMLL::MLClassList, KKMLL::GrayScaleImagesFVList, and KKB::XmlAttributeList.

Definition at line 648 of file KKQueue.h.

649  {
650  if (KKQueue<Entry>::size () <= 0)
651  return NULL;
652 
653  Entry* e = KKQueue<Entry>::back ();
654  KKQueue<Entry>::pop_back ();
655  return e;
656  }
template<class Entry >
KKQueue< Entry >::EntryPtr KKQueue::PopFromFront ( )
virtual

Removes the first element in the container and returns its pointer. If the container is empty will return NULL.

Reimplemented in KKMLL::MLClassList.

Definition at line 596 of file KKQueue.h.

597  {
598  if (KKQueue<Entry>::size () <= 0)
599  {
600  return NULL;
601  }
602 
603  iterator beg = KKQueue<Entry>::begin ();
604  Entry* e = *beg;
605  KKQueue<Entry>::erase (beg);
606  return e;
607  }
std::vector< Entry * >::iterator iterator
Definition: KKQueue.h:88
template<class Entry >
kkint32 KKQueue::PtrToIdx ( EntryConstPtr  _entry) const

returns the index of the 'entry' that has the same pointer as '_entry', if none found returns -1

Definition at line 761 of file KKQueue.h.

762  {
763  return LocateEntry (_entry);
764  }
kkint32 LocateEntry(EntryConstPtr _entry) const
Definition: KKQueue.h:745
template<class Entry >
void KKQueue::PushOnBack ( EntryPtr  _entry)
virtual

Adds '_entry' to the End of the container.

Reimplemented in KKB::XmlAttributeList.

Definition at line 398 of file KKQueue.h.

399  {
400  this->push_back (_entry);
401 
402  EntryPtr e = KKQueue<Entry>::back ();
403 
404  if (e != _entry)
405  {
406  std::cerr << "KKQueue<Entry>::PushOnBack ***ERROR*** Operation Failed!!!" << std::endl;
407  }
408  //vector<Entry*> x;
409  }
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
template<class Entry >
void KKQueue::PushOnFront ( EntryPtr  _entry)
virtual

Adds '_entry' to the Front of the container.

Reimplemented in KKB::XmlAttributeList.

Definition at line 383 of file KKQueue.h.

384  {
385  KKQueue<Entry>::insert (KKQueue<Entry>::begin (), _entry);
386 
387  Entry* e = *KKQueue<Entry>::begin ();
388 
389  if (e != _entry)
390  {
391  std::cout << "Error " << std::endl;
392  }
393 
394  }
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
template<class Entry >
kkint32 KKQueue::QueueSize ( ) const

Same as calling vector<>::size(); returns the number of elements in KKQueue

Definition at line 313 of file KKQueue.h.

314  {
315  return (kkint32)this->size ();
316  }
__int32 kkint32
Definition: KKBaseTypes.h:88
template<class Entry >
void KKQueue::RandomizeOrder ( )

Randomizes the order of the vector.

Implements the "Fisher-Yates Uniform Random Sort"; this implementation was done by Sergiy Fefilatyev (2011-01-27)

Definition at line 469 of file KKQueue.h.

470  {
471  kkint32 i, j;
472  kkuint32 numEntries = KKQueue<Entry>::size ();
473  if (numEntries < 2)
474  return;
475 
476  i = numEntries - 1;
477  while (true)
478  {
479  j = LRand48() % (i + 1);
480  SwapIndexes (i, j );
481  if (i < 1)
482  break;
483  i--;
484  }
485  } /* RandomizeOrder */
__int32 kkint32
Definition: KKBaseTypes.h:88
kkint32 LRand48()
A implementations of the Unix version of rand48 returning a 32 bit integer.
Definition: KKBaseTypes.cpp:36
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
void SwapIndexes(size_t idx1, size_t idx2)
Definition: KKQueue.h:769
template<class Entry >
void KKQueue::RandomizeOrder ( kkint64  seed)

Definition at line 490 of file KKQueue.h.

491  {
492  SRand48 (seed);
493  RandomizeOrder ();
494  } /* RandomizeOrder */
void RandomizeOrder()
Randomizes the order of the vector.
Definition: KKQueue.h:469
void SRand48(kkint64 _seed)
Seeds the Lrand48 functions with the parameters passed to it.
Definition: KKBaseTypes.cpp:49
template<class Entry >
void KKQueue::RandomizeOrder ( RandomNumGenerator randomVariable)

Randomizes the order of the vector.

Implements the "Fisher-Yates Uniform Random Sort"; this implementation was done by Sergiy Fefilatyev (2011-01-27)

Definition at line 504 of file KKQueue.h.

505  {
506  kkint32 i, j;
507  kkuint32 numEntries = KKQueue<Entry>::size ();
508  if (numEntries < 2)
509  return;
510 
511  i = numEntries - 1;
512  while (true)
513  {
514  j = randomVariable.Next () % (i + 1);
515  SwapIndexes (i, j );
516  if (i < 1)
517  break;
518  i--;
519  }
520  } /* RandomizeOrder */
__int32 kkint32
Definition: KKBaseTypes.h:88
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
void SwapIndexes(size_t idx1, size_t idx2)
Definition: KKQueue.h:769
template<class Entry >
KKQueue< Entry >::EntryPtr KKQueue::RemoveFirst ( )
inlinevirtual

same as PopFromFront

Definition at line 611 of file KKQueue.h.

612  {
613  return PopFromFront ();
614  }
virtual EntryPtr PopFromFront()
Definition: KKQueue.h:596
template<class Entry >
KKQueue< Entry >::EntryPtr KKQueue::RemoveLast ( )
inlinevirtual

same as PopFromBack

Definition at line 619 of file KKQueue.h.

620  {
621  return PopFromBack ();
622  }
virtual EntryPtr PopFromBack()
Definition: KKQueue.h:648
template<class Entry>
void KKQueue::SetIdxToPtr ( kkuint32  _idx,
Entry *  _ptr 
)

Definition at line 700 of file KKQueue.h.

703  {
704  if ((kkuint32)_idx >= KKQueue<Entry>::size ())
705  return;
706 
707  std::vector<Entry*>::operator[] (_idx) = _ptr;
708  } /* SetIdxToPtr */
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
template<class Entry >
void KKQueue::SwapIndexes ( size_t  idx1,
size_t  idx2 
)

Definition at line 769 of file KKQueue.h.

770  {
771  if ((idx1 < 0) || (idx1 >= KKQueue<Entry>::size ()) ||
772  (idx2 < 0) || (idx2 >= KKQueue<Entry>::size ())
773  )
774  {
775  std::cerr << std::endl;
776 
777  std::cerr << " *** ERROR *** (KKQueue::SwapIndexes) Indexes["
778  << (kkint32)idx1 << ", " << (kkint32)idx2 << "] Out of Range."
779  << std::endl;
780 
781  std::cerr << " KKQueue Size[" << (kkint32)KKQueue<Entry>::size () << "]."
782  << std::endl
783  << std::endl;
784 
785  exit (1);
786  }
787 
788  //vector<typename Entry*>& us (*this);
789  EntryPtr tempPtr = std::vector<Entry*>::operator[] (idx1);
790 
791  // (*this)[idx1];
792 
793  std::vector<EntryPtr>::operator[] (idx1) = std::vector<EntryPtr>::operator[] (idx2);
794  std::vector<EntryPtr>::operator[] (idx2) = tempPtr;
795  //(*this)[idx1] = (*this)[idx2];
796  //(*this)[idx2] = tempPtr;
797  } /* SwapIndexes */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
__int32 kkint32
Definition: KKBaseTypes.h:88
KKQueue(bool _owner=true)
Definition: KKQueue.h:219

The documentation for this class was generated from the following file: