msm::PriorityQueue< T > Class Template Reference

#include <MsmMap.h>

List of all members.

Public Member Functions

 PriorityQueue (int nelems=0)
void init (int nelems)
void clear ()
void insert (const T &t)
void remove (T &t)


Detailed Description

template<class T>
class msm::PriorityQueue< T >

Definition at line 337 of file MsmMap.h.


Constructor & Destructor Documentation

template<class T>
msm::PriorityQueue< T >::PriorityQueue ( int  nelems = 0  )  [inline]

Definition at line 339 of file MsmMap.h.

References msm::PriorityQueue< T >::init().

00339                                   {
00340         if (nelems > 0)  init(nelems);
00341       }


Member Function Documentation

template<class T>
void msm::PriorityQueue< T >::clear (  )  [inline]

Definition at line 346 of file MsmMap.h.

References msm::Array< T >::resize().

00346                    {
00347         a.resize(0);
00348       }

template<class T>
void msm::PriorityQueue< T >::init ( int  nelems  )  [inline]

Definition at line 342 of file MsmMap.h.

References msm::Array< T >::resize().

Referenced by msm::PriorityQueue< T >::PriorityQueue().

00342                             {
00343         a.resize(nelems);  // pre-allocate space
00344         a.resize(0);       // nothing stored yet (does not free memory)
00345       }

template<class T>
void msm::PriorityQueue< T >::insert ( const T &  t  )  [inline]

Definition at line 349 of file MsmMap.h.

References msm::Array< T >::append().

00349                               {
00350         a.append(t);
00351         upheap();
00352       }

template<class T>
void msm::PriorityQueue< T >::remove ( T &  t  )  [inline]

Definition at line 353 of file MsmMap.h.

References msm::Array< T >::len(), and msm::Array< T >::resize().

00353                         {
00354         int last = a.len() - 1;
00355         if (last < 0) return;
00356         t = a[0];
00357         if (last > 0) a[0] = a[last];
00358         a.resize(last);  // remove last element from array
00359         downheap();
00360       }


The documentation for this class was generated from the following file:
Generated on Wed Sep 20 01:17:20 2017 for NAMD by  doxygen 1.4.7