yosys-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Minisat::vec< T, _Size > Class Template Reference

#include <Vec.h>

+ Collaboration diagram for Minisat::vec< T, _Size >:

Public Types

typedef _Size Size
 

Public Member Functions

 vec ()
 
 vec (Size size)
 
 vec (Size size, const T &pad)
 
 ~vec ()
 
 operator T * (void)
 
Size size (void) const
 
void shrink (Size nelems)
 
void shrink_ (Size nelems)
 
int capacity (void) const
 
void capacity (Size min_cap)
 
void growTo (Size size)
 
void growTo (Size 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[] (Size index) const
 
T & operator[] (Size index)
 
void copyTo (vec< T > &copy) const
 
void moveTo (vec< T > &dest)
 

Private Member Functions

vec< T > & operator= (vec< T > &other)
 
 vec (vec< T > &other)
 

Static Private Member Functions

static Size max (Size x, Size y)
 

Private Attributes

T * data
 
Size sz
 
Size cap
 

Detailed Description

template<class T, class _Size = int>
class Minisat::vec< T, _Size >

Definition at line 39 of file Vec.h.

Member Typedef Documentation

template<class T, class _Size = int>
typedef _Size Minisat::vec< T, _Size >::Size

Definition at line 41 of file Vec.h.

Constructor & Destructor Documentation

template<class T, class _Size = int>
Minisat::vec< T, _Size >::vec ( vec< T > &  other)
private
template<class T, class _Size = int>
Minisat::vec< T, _Size >::vec ( )
inline

Definition at line 55 of file Vec.h.

55 : data(NULL), sz(0), cap(0) { }
T * data
Definition: Vec.h:43
Size sz
Definition: Vec.h:44
#define NULL
Size cap
Definition: Vec.h:45
template<class T, class _Size = int>
Minisat::vec< T, _Size >::vec ( Size  size)
inlineexplicit

Definition at line 56 of file Vec.h.

56 : data(NULL), sz(0), cap(0) { growTo(size); }
void growTo(Size size)
Definition: Vec.h:117
T * data
Definition: Vec.h:43
Size size(void) const
Definition: Vec.h:64
Size sz
Definition: Vec.h:44
#define NULL
Size cap
Definition: Vec.h:45
template<class T, class _Size = int>
Minisat::vec< T, _Size >::vec ( Size  size,
const T &  pad 
)
inline

Definition at line 57 of file Vec.h.

57 : data(NULL), sz(0), cap(0) { growTo(size, pad); }
void growTo(Size size)
Definition: Vec.h:117
T * data
Definition: Vec.h:43
Size size(void) const
Definition: Vec.h:64
Size sz
Definition: Vec.h:44
#define NULL
Size cap
Definition: Vec.h:45
template<class T, class _Size = int>
Minisat::vec< T, _Size >::~vec ( )
inline

Definition at line 58 of file Vec.h.

58 { clear(true); }
void clear(bool dealloc=false)
Definition: Vec.h:125

Member Function Documentation

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

Definition at line 67 of file Vec.h.

67 { return cap; }
Size cap
Definition: Vec.h:45

+ Here is the caller graph for this function:

template<class T , class _Size >
void Minisat::vec< T, _Size >::capacity ( Size  min_cap)

Definition at line 98 of file Vec.h.

98  {
99  if (cap >= min_cap) return;
100  Size add = max((min_cap - cap + 1) & ~1, ((cap >> 1) + 2) & ~1); // NOTE: grow by approximately 3/2
101  const Size size_max = std::numeric_limits<Size>::max();
102  if ( ((size_max <= std::numeric_limits<int>::max()) && (add > size_max - cap))
103  || (((data = (T*)::realloc(data, (cap += add) * sizeof(T))) == NULL) && errno == ENOMEM) )
104  throw OutOfMemoryException();
105  }
_Size Size
Definition: Vec.h:41
T * data
Definition: Vec.h:43
static Size max(Size x, Size y)
Definition: Vec.h:51
#define NULL
Size cap
Definition: Vec.h:45
template<class T , class _Size >
void Minisat::vec< T, _Size >::clear ( bool  dealloc = false)

Definition at line 125 of file Vec.h.

125  {
126  if (data != NULL){
127  for (Size i = 0; i < sz; i++) data[i].~T();
128  sz = 0;
129  if (dealloc) free(data), data = NULL, cap = 0; } }
_Size Size
Definition: Vec.h:41
void free(void *)
T * data
Definition: Vec.h:43
Size sz
Definition: Vec.h:44
#define NULL
Size cap
Definition: Vec.h:45

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 92 of file Vec.h.

92 { copy.clear(); copy.growTo(sz); for (Size i = 0; i < sz; i++) copy[i] = data[i]; }
_Size Size
Definition: Vec.h:41
void growTo(Size size)
Definition: Vec.h:117
T * data
Definition: Vec.h:43
Size sz
Definition: Vec.h:44
void clear(bool dealloc=false)
Definition: Vec.h:125

+ Here is the caller graph for this function:

template<class T , class _Size >
void Minisat::vec< T, _Size >::growTo ( Size  size)

Definition at line 117 of file Vec.h.

117  {
118  if (sz >= size) return;
119  capacity(size);
120  for (Size i = sz; i < size; i++) new (&data[i]) T();
121  sz = size; }
_Size Size
Definition: Vec.h:41
int capacity(void) const
Definition: Vec.h:67
T * data
Definition: Vec.h:43
Size size(void) const
Definition: Vec.h:64
Size sz
Definition: Vec.h:44

+ Here is the caller graph for this function:

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

Definition at line 109 of file Vec.h.

109  {
110  if (sz >= size) return;
111  capacity(size);
112  for (Size i = sz; i < size; i++) data[i] = pad;
113  sz = size; }
_Size Size
Definition: Vec.h:41
int capacity(void) const
Definition: Vec.h:67
T * data
Definition: Vec.h:43
Size size(void) const
Definition: Vec.h:64
Size sz
Definition: Vec.h:44
template<class T, class _Size = int>
const T& Minisat::vec< T, _Size >::last ( void  ) const
inline

Definition at line 84 of file Vec.h.

84 { return data[sz-1]; }
T * data
Definition: Vec.h:43
Size sz
Definition: Vec.h:44

+ Here is the caller graph for this function:

template<class T, class _Size = int>
T& Minisat::vec< T, _Size >::last ( void  )
inline

Definition at line 85 of file Vec.h.

85 { return data[sz-1]; }
T * data
Definition: Vec.h:43
Size sz
Definition: Vec.h:44
template<class T, class _Size = int>
static Size Minisat::vec< T, _Size >::max ( Size  x,
Size  y 
)
inlinestaticprivate

Definition at line 51 of file Vec.h.

51 { return (x > y) ? x : y; }
template<class T, class _Size = int>
void Minisat::vec< T, _Size >::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; }
T * data
Definition: Vec.h:43
Size sz
Definition: Vec.h:44
#define NULL
void clear(bool dealloc=false)
Definition: Vec.h:125
Size cap
Definition: Vec.h:45

+ Here is the caller graph for this function:

template<class T, class _Size = int>
Minisat::vec< T, _Size >::operator T * ( void  )
inline

Definition at line 61 of file Vec.h.

61 { return data; }
T * data
Definition: Vec.h:43
template<class T, class _Size = int>
vec<T>& Minisat::vec< T, _Size >::operator= ( vec< T > &  other)
private
template<class T, class _Size = int>
const T& Minisat::vec< T, _Size >::operator[] ( Size  index) const
inline

Definition at line 88 of file Vec.h.

88 { return data[index]; }
T * data
Definition: Vec.h:43
template<class T, class _Size = int>
T& Minisat::vec< T, _Size >::operator[] ( Size  index)
inline

Definition at line 89 of file Vec.h.

89 { return data[index]; }
T * data
Definition: Vec.h:43
template<class T, class _Size = int>
void Minisat::vec< T, _Size >::pop ( void  )
inline

Definition at line 78 of file Vec.h.

78 { assert(sz > 0); sz--, data[sz].~T(); }
T * data
Definition: Vec.h:43
Size sz
Definition: Vec.h:44

+ Here is the caller graph for this function:

template<class T, class _Size = int>
void Minisat::vec< T, _Size >::push ( void  )
inline

Definition at line 74 of file Vec.h.

74 { if (sz == cap) capacity(sz+1); new (&data[sz]) T(); sz++; }
int capacity(void) const
Definition: Vec.h:67
T * data
Definition: Vec.h:43
Size sz
Definition: Vec.h:44
Size cap
Definition: Vec.h:45

+ Here is the caller graph for this function:

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

Definition at line 76 of file Vec.h.

76 { if (sz == cap) capacity(sz+1); new (&data[sz++]) T(elem); }
int capacity(void) const
Definition: Vec.h:67
T * data
Definition: Vec.h:43
Size sz
Definition: Vec.h:44
Size cap
Definition: Vec.h:45
template<class T, class _Size = int>
void Minisat::vec< T, _Size >::push_ ( const T &  elem)
inline

Definition at line 77 of file Vec.h.

77 { assert(sz < cap); data[sz++] = elem; }
T * data
Definition: Vec.h:43
Size sz
Definition: Vec.h:44
Size cap
Definition: Vec.h:45

+ Here is the caller graph for this function:

template<class T, class _Size = int>
void Minisat::vec< T, _Size >::shrink ( Size  nelems)
inline

Definition at line 65 of file Vec.h.

65 { assert(nelems <= sz); for (Size i = 0; i < nelems; i++) sz--, data[sz].~T(); }
_Size Size
Definition: Vec.h:41
T * data
Definition: Vec.h:43
Size sz
Definition: Vec.h:44

+ Here is the caller graph for this function:

template<class T, class _Size = int>
void Minisat::vec< T, _Size >::shrink_ ( Size  nelems)
inline

Definition at line 66 of file Vec.h.

66 { assert(nelems <= sz); sz -= nelems; }
Size sz
Definition: Vec.h:44
template<class T, class _Size = int>
Size Minisat::vec< T, _Size >::size ( void  ) const
inline

Definition at line 64 of file Vec.h.

64 { return sz; }
Size sz
Definition: Vec.h:44

Field Documentation

template<class T, class _Size = int>
Size Minisat::vec< T, _Size >::cap
private

Definition at line 45 of file Vec.h.

template<class T, class _Size = int>
T* Minisat::vec< T, _Size >::data
private

Definition at line 43 of file Vec.h.

template<class T, class _Size = int>
Size Minisat::vec< T, _Size >::sz
private

Definition at line 44 of file Vec.h.


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