NAMD
Public Member Functions | Protected Attributes | List of all members
SortedArray< Elem > Class Template Reference

#include <ResizeArrayRaw.h>

Inheritance diagram for SortedArray< Elem >:
SortableResizeArray< Elem > ResizeArray< Elem > UniqueSortedArray< Elem >

Public Member Functions

 SortedArray (void)
 
 SortedArray (int s)
 
 SortedArray (SortedArray< Elem > &sa)
 
 SortedArray (SortableResizeArray< Elem > &ra)
 
SortedArray< Elem > & operator= (SortedArray< Elem > &sa)
 
SortedArray< Elem > & operator= (SortableResizeArray< Elem > &ra)
 
int load (const Elem &elem)
 
int add (const Elem &elem)
 
void del (const Elem &elem)
 
void sort (void)
 
int bsearch (const Elem &elem)
 
int insert (const Elem &elem)
 
int index (const Elem &elem)
 
Elem * find (const Elem &elem)
 
- Public Member Functions inherited from SortableResizeArray< Elem >
 SortableResizeArray (void)
 
 SortableResizeArray (int size)
 
 SortableResizeArray (ResizeArray< Elem > &ra)
 
 SortableResizeArray (SortableResizeArray< Elem > &ra)
 
 SortableResizeArray (const ResizeArray< Elem > *ra)
 
 SortableResizeArray (const SortableResizeArray< Elem > *ra)
 
 SortableResizeArray (Elem **const r, int numElem, int maxElem)
 
SortableResizeArray< Elem > & operator= (SortableResizeArray< Elem > &sa)
 
 ~SortableResizeArray (void)
 
void init (void)
 
void sort (void)
 
void sort (int bot, int top)
 
void uniq (void)
 
int bsearch (const Elem &elem) const
 
- Public Member Functions inherited from ResizeArray< Elem >
iterator begin (void)
 
iterator end (void)
 
const_iterator const_begin (void) const
 
const_iterator const_end (void) const
 
 ResizeArray (void)
 
 ResizeArray (int s)
 
void copy (ResizeArray< Elem > &ra)
 
void swap (ResizeArray< Elem > &ra)
 
bool shared () const
 
 ResizeArray (Elem **array, int arraySize, int allocSize=0)
 
 ~ResizeArray (void)
 
void resize (int i)
 
void reserve (int i)
 
void clear ()
 
void setall (const Elem &elem)
 
int add (const Elem &elem)
 
void del (int index, int num=1)
 
int insert (const Elem &elem, int index)
 
Elem & item (int i)
 
Elem & operator[] (int index)
 
const Elem & operator[] (int index) const
 
int size (void) const
 
int find (const Elem &e) const
 

Protected Attributes

int isSorted
 
- Protected Attributes inherited from ResizeArray< Elem >
ResizeArrayRaw< Elem > rep
 

Additional Inherited Members

- Public Types inherited from ResizeArray< Elem >
typedef Elem * iterator
 
typedef const Elem * const_iterator
 

Detailed Description

template<class Elem>
class SortedArray< Elem >

Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000 by The Board of Trustees of the University of Illinois. All rights reserved.

Definition at line 30 of file ResizeArrayRaw.h.

Constructor & Destructor Documentation

◆ SortedArray() [1/4]

template<class Elem>
SortedArray< Elem >::SortedArray ( void  )
inline

Definition at line 20 of file SortedArray.h.

◆ SortedArray() [2/4]

template<class Elem>
SortedArray< Elem >::SortedArray ( int  s)
inline

Definition at line 24 of file SortedArray.h.

◆ SortedArray() [3/4]

template<class Elem>
SortedArray< Elem >::SortedArray ( SortedArray< Elem > &  sa)
inline

Definition at line 28 of file SortedArray.h.

29  if(!(isSorted = sa.isSorted)) sort();
30  isSorted = 1;
31  }
void sort(void)
Definition: SortedArray.h:66

◆ SortedArray() [4/4]

template<class Elem>
SortedArray< Elem >::SortedArray ( SortableResizeArray< Elem > &  ra)
inline

Definition at line 33 of file SortedArray.h.

33  :
35  sort(); isSorted = 1;
36  }
void sort(void)
Definition: SortedArray.h:66

Member Function Documentation

◆ add()

template<class Elem>
int SortedArray< Elem >::add ( const Elem &  elem)
inline

◆ bsearch()

template<class Elem>
int SortedArray< Elem >::bsearch ( const Elem &  elem)
inline

Definition at line 68 of file SortedArray.h.

Referenced by SortedArray< PatchElem >::del(), and SortedArray< PatchElem >::index().

68  {
69  if (!isSorted) sort();
71  }
void sort(void)
Definition: SortedArray.h:66

◆ del()

template<class Elem>
void SortedArray< Elem >::del ( const Elem &  elem)
inline

Definition at line 59 of file SortedArray.h.

Referenced by PatchMgr::sendMovePatches(), PatchMgr::sendOneHomePatch(), Patch::unregisterDEdaSumDeposit(), Patch::unregisterForceDeposit(), Patch::unregisterPositionPickup(), and Patch::unregisterPsiSumDeposit().

59  {
60  int found = bsearch(elem);
61  if (this->size() != 0 && this->rep[found] == elem) {
63  }
64  }
ResizeArrayRaw< Elem > rep
Definition: ResizeArray.h:31
int size(void) const
Definition: ResizeArray.h:131
void del(int index, int num=1)
Definition: ResizeArray.h:108
int bsearch(const Elem &elem)
Definition: SortedArray.h:68

◆ find()

template<class Elem>
Elem * SortedArray< Elem >::find ( const Elem &  elem)
inline

Definition at line 94 of file SortedArray.h.

Referenced by ComputeQM::doWork(), PatchMgr::homePatch(), Molecule::prepare_qm(), ComputeQM::processFullQM(), HomePatch::qmSwapAtoms(), ComputeQMMgr::recvPntChrg(), and PatchMgr::~PatchMgr().

94  {
95  int found = bsearch(elem);
96  if ( found < 0 || found == this->size() )
97  return ((Elem *)NULL);
98  if (this->rep[found] == elem) {
99  return (&(this->rep[found]));
100  } else {
101  return ((Elem *)NULL);
102  }
103 }
ResizeArrayRaw< Elem > rep
Definition: ResizeArray.h:31
int size(void) const
Definition: ResizeArray.h:131
int bsearch(const Elem &elem)
Definition: SortedArray.h:68

◆ index()

template<class Elem>
int SortedArray< Elem >::index ( const Elem &  elem)
inline

Definition at line 75 of file SortedArray.h.

75 { return bsearch(elem); }
int bsearch(const Elem &elem)
Definition: SortedArray.h:68

◆ insert()

template<class Elem>
int SortedArray< Elem >::insert ( const Elem &  elem)
inline

Definition at line 81 of file SortedArray.h.

Referenced by SortedArray< PatchElem >::add(), lssDistSort::lssDistSort(), lssDistSort::operator=(), Molecule::prepare_qm(), and ComputeQMMgr::procQMRes().

81  {
82  int found = bsearch(elem);
83  if (found == -1) {
84  return (ResizeArray<Elem>::insert(elem, 0));
85  }
86  if (found == (this->size()-1) && this->rep[found] < elem) {
87  return (ResizeArray<Elem>::insert(elem, this->size()));
88  } else {
89  return (ResizeArray<Elem>::insert(elem, found));
90  }
91 }
ResizeArrayRaw< Elem > rep
Definition: ResizeArray.h:31
int size(void) const
Definition: ResizeArray.h:131
int bsearch(const Elem &elem)
Definition: SortedArray.h:68

◆ load()

template<class Elem>
int SortedArray< Elem >::load ( const Elem &  elem)
inline

Definition at line 50 of file SortedArray.h.

Referenced by PatchMgr::createHomePatch(), PatchMgr::movePatch(), ComputeQM::processFullQM(), and ComputeQMMgr::recvPntChrg().

50  {
51  isSorted = 0;
52  return(ResizeArray<Elem>::add(elem));
53  }

◆ operator=() [1/2]

template<class Elem>
SortedArray<Elem>& SortedArray< Elem >::operator= ( SortedArray< Elem > &  sa)
inline

Definition at line 38 of file SortedArray.h.

Referenced by UniqueSortedArray< PatchElem >::operator=().

38  {
40  isSorted = sa.isSorted;
41  return(*this);
42  }
SortableResizeArray< Elem > & operator=(SortableResizeArray< Elem > &sa)

◆ operator=() [2/2]

template<class Elem>
SortedArray<Elem>& SortedArray< Elem >::operator= ( SortableResizeArray< Elem > &  ra)
inline

Definition at line 44 of file SortedArray.h.

44  {
46  sort(); isSorted = 1;
47  return(*this);
48  }
SortableResizeArray< Elem > & operator=(SortableResizeArray< Elem > &sa)
void sort(void)
Definition: SortedArray.h:66

◆ sort()

template<class Elem>
void SortedArray< Elem >::sort ( void  )
inline

Member Data Documentation

◆ isSorted

template<class Elem>
int SortedArray< Elem >::isSorted
protected

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