ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
Minisat::vec< T > Class Template Reference

#include <Vec.h>

Public Member Functions

 vec ()
 
 vec (int size)
 
 vec (int size, const T &pad)
 
 ~vec ()
 
 operator T* (void)
 
int size (void) const
 
void shrink (int nelems)
 
void shrink_ (int nelems)
 
int capacity (void) const
 
void capacity (int min_cap)
 
void growTo (int size)
 
void growTo (int size, const T &pad)
 
void clear (bool dealloc=false)
 
void push (void)
 
void push (const T &elem)
 
void push_ (const T &elem)
 
void pop (void)
 
const T & last (void) const
 
T & last (void)
 
const T & operator[] (int index) const
 
T & operator[] (int index)
 
void copyTo (vec< T > &copy) const
 
void moveTo (vec< T > &dest)
 

Detailed Description

template<class T>
class Minisat::vec< T >

Definition at line 40 of file Vec.h.

Constructor & Destructor Documentation

◆ vec() [1/3]

template<class T>
Minisat::vec< T >::vec ( )
inline

Definition at line 56 of file Vec.h.

56: data(NULL) , sz(0) , cap(0) { }

◆ vec() [2/3]

template<class T>
Minisat::vec< T >::vec ( int size)
inlineexplicit

Definition at line 57 of file Vec.h.

57: data(NULL) , sz(0) , cap(0) { growTo(size); }
void growTo(int size)
Definition Vec.h:118
int size(void) const
Definition Vec.h:65
Here is the call graph for this function:

◆ vec() [3/3]

template<class T>
Minisat::vec< T >::vec ( int size,
const T & pad )
inline

Definition at line 58 of file Vec.h.

58: data(NULL) , sz(0) , cap(0) { growTo(size, pad); }
Here is the call graph for this function:

◆ ~vec()

template<class T>
Minisat::vec< T >::~vec ( )
inline

Definition at line 59 of file Vec.h.

59{ clear(true); }
void clear(bool dealloc=false)
Definition Vec.h:126
Here is the call graph for this function:

Member Function Documentation

◆ capacity() [1/2]

template<class T>
void Minisat::vec< T >::capacity ( int min_cap)

Definition at line 97 of file Vec.h.

97 {
98 if (cap >= min_cap) return;
99 int add = imax((min_cap - cap + 1) & ~1, ((cap >> 1) + 2) & ~1); // NOTE: grow by approximately 3/2
100 if (add > INT_MAX - cap || (((data = (T*)::realloc(data, (cap += add) * sizeof(T))) == NULL) && errno == ENOMEM))
101#ifdef __wasm
102 abort();
103#else
104 throw OutOfMemoryException();
105#endif
106 }
VOID_HACK abort()
Here is the call graph for this function:

◆ capacity() [2/2]

template<class T>
int Minisat::vec< T >::capacity ( void ) const
inline

Definition at line 68 of file Vec.h.

68{ return cap; }
Here is the caller graph for this function:

◆ clear()

template<class T>
void Minisat::vec< T >::clear ( bool dealloc = false)

Definition at line 126 of file Vec.h.

126 {
127 if (data != NULL){
128 for (int i = 0; i < sz; i++) data[i].~T();
129 sz = 0;
130 if (dealloc) free(data), data = NULL, cap = 0; } }
VOID_HACK free()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ copyTo()

template<class T>
void Minisat::vec< T >::copyTo ( vec< T > & copy) const
inline

Definition at line 92 of file Vec.h.

92{ copy.clear(); copy.growTo(sz); for (int i = 0; i < sz; i++) copy[i] = data[i]; }
Here is the caller graph for this function:

◆ growTo() [1/2]

template<class T>
void Minisat::vec< T >::growTo ( int size)

Definition at line 118 of file Vec.h.

118 {
119 if (sz >= size) return;
120 capacity(size);
121 for (int i = sz; i < size; i++) new (&data[i]) T();
122 sz = size; }
int capacity(void) const
Definition Vec.h:68
Here is the call graph for this function:
Here is the caller graph for this function:

◆ growTo() [2/2]

template<class T>
void Minisat::vec< T >::growTo ( int size,
const T & pad )

Definition at line 110 of file Vec.h.

110 {
111 if (sz >= size) return;
112 capacity(size);
113 for (int i = sz; i < size; i++) data[i] = pad;
114 sz = size; }
Here is the call graph for this function:

◆ last() [1/2]

template<class T>
T & Minisat::vec< T >::last ( void )
inline

Definition at line 85 of file Vec.h.

85{ return data[sz-1]; }

◆ last() [2/2]

template<class T>
const T & Minisat::vec< T >::last ( void ) const
inline

Definition at line 84 of file Vec.h.

84{ return data[sz-1]; }
Here is the caller graph for this function:

◆ moveTo()

template<class T>
void Minisat::vec< T >::moveTo ( vec< T > & dest)
inline

Definition at line 93 of file Vec.h.

93{ dest.clear(true); dest.data = data; dest.sz = sz; dest.cap = cap; data = NULL; sz = 0; cap = 0; }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator T*()

template<class T>
Minisat::vec< T >::operator T* ( void )
inline

Definition at line 62 of file Vec.h.

62{ return data; }

◆ operator[]() [1/2]

template<class T>
T & Minisat::vec< T >::operator[] ( int index)
inline

Definition at line 89 of file Vec.h.

89{ return data[index]; }

◆ operator[]() [2/2]

template<class T>
const T & Minisat::vec< T >::operator[] ( int index) const
inline

Definition at line 88 of file Vec.h.

88{ return data[index]; }

◆ pop()

template<class T>
void Minisat::vec< T >::pop ( void )
inline

Definition at line 78 of file Vec.h.

78{ assert(sz > 0); sz--, data[sz].~T(); }
#define assert(ex)
Definition util_old.h:213
Here is the caller graph for this function:

◆ push() [1/2]

template<class T>
void Minisat::vec< T >::push ( const T & elem)
inline

Definition at line 76 of file Vec.h.

76{ if (sz == cap) capacity(sz+1); data[sz++] = elem; }
Here is the call graph for this function:

◆ push() [2/2]

template<class T>
void Minisat::vec< T >::push ( void )
inline

Definition at line 75 of file Vec.h.

75{ if (sz == cap) capacity(sz+1); new (&data[sz]) T(); sz++; }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ push_()

template<class T>
void Minisat::vec< T >::push_ ( const T & elem)
inline

Definition at line 77 of file Vec.h.

77{ assert(sz < cap); data[sz++] = elem; }

◆ shrink()

template<class T>
void Minisat::vec< T >::shrink ( int nelems)
inline

Definition at line 66 of file Vec.h.

66{ assert(nelems <= sz); for (int i = 0; i < nelems; i++) sz--, data[sz].~T(); }
Here is the caller graph for this function:

◆ shrink_()

template<class T>
void Minisat::vec< T >::shrink_ ( int nelems)
inline

Definition at line 67 of file Vec.h.

67{ assert(nelems <= sz); sz -= nelems; }

◆ size()

template<class T>
int Minisat::vec< T >::size ( void ) const
inline

Definition at line 65 of file Vec.h.

65{ return sz; }
Here is the caller graph for this function:

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