NAMD
Public Member Functions | List of all members
SortableResizeArray< Elem > Class Template Reference

#include <ResizeArrayRaw.h>

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

Public Member Functions

 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
 

Additional Inherited Members

- Public Types inherited from ResizeArray< Elem >
typedef Elem * iterator
 
typedef const Elem * const_iterator
 
- Protected Attributes inherited from ResizeArray< Elem >
ResizeArrayRaw< Elem > rep
 

Detailed Description

template<class Elem>
class SortableResizeArray< 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 29 of file ResizeArrayRaw.h.

Constructor & Destructor Documentation

◆ SortableResizeArray() [1/7]

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

Definition at line 49 of file SortableResizeArray.h.

◆ SortableResizeArray() [2/7]

template<class Elem>
SortableResizeArray< Elem >::SortableResizeArray ( int  size)
inline

Definition at line 51 of file SortableResizeArray.h.

51 : ResizeArray<Elem>(size) { init(); }
int size(void) const
Definition: ResizeArray.h:131

◆ SortableResizeArray() [3/7]

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

Definition at line 53 of file SortableResizeArray.h.

53  :
54  ResizeArray<Elem>(ra) { init(); }

◆ SortableResizeArray() [4/7]

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

Definition at line 56 of file SortableResizeArray.h.

56  :
57  ResizeArray<Elem>(ra) { init(); }

◆ SortableResizeArray() [5/7]

template<class Elem>
SortableResizeArray< Elem >::SortableResizeArray ( const ResizeArray< Elem > *  ra)
inline

Definition at line 59 of file SortableResizeArray.h.

59  :
60  ResizeArray<Elem>(ra) { init(); }

◆ SortableResizeArray() [6/7]

template<class Elem>
SortableResizeArray< Elem >::SortableResizeArray ( const SortableResizeArray< Elem > *  ra)
inline

Definition at line 62 of file SortableResizeArray.h.

62  :
63  ResizeArray<Elem>(ra) { init(); }

◆ SortableResizeArray() [7/7]

template<class Elem>
SortableResizeArray< Elem >::SortableResizeArray ( Elem **const  r,
int  numElem,
int  maxElem 
)
inline

Definition at line 65 of file SortableResizeArray.h.

65  :
66  ResizeArray<Elem>(r,numElem,maxElem) { init(); }

◆ ~SortableResizeArray()

template<class Elem>
SortableResizeArray< Elem >::~SortableResizeArray ( void  )
inline

Definition at line 73 of file SortableResizeArray.h.

73 { }

Member Function Documentation

◆ bsearch()

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

Definition at line 106 of file SortableResizeArray.h.

106  {
107  int test;
108  int bot = -1;
109  int top = this->size();
110  if (this->size() == 0) return (-1);
111  while (top - bot > 1) {
112  if ( this->rep.array[test = (bot+top)/2] < elem )
113  bot = test;
114  else
115  top = test;
116  }
117  return(top);
118  }
ResizeArrayRaw< Elem > rep
Definition: ResizeArray.h:31
int size(void) const
Definition: ResizeArray.h:131

◆ init()

template<class Elem>
void SortableResizeArray< Elem >::init ( void  )
inline

Definition at line 75 of file SortableResizeArray.h.

Referenced by SortableResizeArray< PatchElem >::SortableResizeArray().

75 { }

◆ operator=()

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

Definition at line 68 of file SortableResizeArray.h.

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

68  {
70  return(*this);
71  }

◆ sort() [1/2]

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

Definition at line 77 of file SortableResizeArray.h.

Referenced by ComputePmeMgr::initialize(), SortedArray< PatchElem >::sort(), and SortableResizeArray< PatchElem >::sort().

77 { sort(0, this->rep.size()-1); }
ResizeArrayRaw< Elem > rep
Definition: ResizeArray.h:31

◆ sort() [2/2]

template<class Elem>
void SortableResizeArray< Elem >::sort ( int  bot,
int  top 
)
inline

Definition at line 82 of file SortableResizeArray.h.

82  {
83  int index, size;
84  if (top > this->rep.size()) top = this->rep.size();
85  size = top - bot + 1;
86 
87  // Make all sub-heaps
88  for ( index = size/2-1; index > 0; index-- )
89  siftup(bot, index, size);
90 
91  // Take top element of overall heap, and put on top
92  for ( index = size; index > 1; index-- ) {
93  siftup(bot, 0, index);
94  swap(bot, 0, index-1);
95  }
96  }
ResizeArrayRaw< Elem > rep
Definition: ResizeArray.h:31
int size(void) const
Definition: ResizeArray.h:131
void swap(Array< T > &s, Array< T > &t)
Definition: MsmMap.h:319
Index index
Definition: Parameters.C:155

◆ uniq()

template<class Elem >
void SortableResizeArray< Elem >::uniq ( void  )
inline

Definition at line 123 of file SortableResizeArray.h.

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

123  {
124  if (this->size()) {
125  int oldIndex=0;
126  int newIndex=0;
127  while (++oldIndex < this->size()) {
128  if ( ! ( this->rep.array[oldIndex] == this->rep.array[newIndex] ) ) {
129  if (++newIndex != oldIndex)
130  memcpy((void *)&(this->rep.array[newIndex]),
131  (void *)&(this->rep.array[oldIndex]),
132  sizeof(Elem));
133  } else {
134  this->rep.array[oldIndex].~Elem();
135  }
136  }
137  this->rep.arraySize = ++newIndex;
138  }
139 }
ResizeArrayRaw< Elem > rep
Definition: ResizeArray.h:31
int size(void) const
Definition: ResizeArray.h:131

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