abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Minisat::Queue< T > Class Template Reference

#include <Queue.h>

Public Types

typedef T Key
 

Public Member Functions

 Queue ()
 
void clear (bool dealloc=false)
 
int size () const
 
const T & operator[] (int index) const
 
T & operator[] (int index)
 
peek () const
 
void pop ()
 
void insert (T elem)
 

Private Attributes

vec< T > buf
 
int first
 
int end
 

Detailed Description

template<class T>
class Minisat::Queue< T >

Definition at line 31 of file Queue.h.

Member Typedef Documentation

template<class T>
typedef T Minisat::Queue< T >::Key

Definition at line 37 of file Queue.h.

Constructor & Destructor Documentation

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

Definition at line 39 of file Queue.h.

39 : buf(1), first(0), end(0) {}
int first
Definition: Queue.h:33
vec< T > buf
Definition: Queue.h:32

Member Function Documentation

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

Definition at line 41 of file Queue.h.

41 { buf.clear(dealloc); buf.growTo(1); first = end = 0; }
int first
Definition: Queue.h:33
vec< T > buf
Definition: Queue.h:32
template<class T>
void Minisat::Queue< T >::insert ( elem)
inline

Definition at line 49 of file Queue.h.

49  { // INVARIANT: buf[end] is always unused
50  buf[end++] = elem;
51  if (end == buf.size()) end = 0;
52  if (first == end){ // Resize:
53  vec<T> tmp((buf.size()*3 + 1) >> 1);
54  //**/printf("queue alloc: %d elems (%.1f MB)\n", tmp.size(), tmp.size() * sizeof(T) / 1000000.0);
55  int j, i = 0;
56  for (j = first; j < buf.size(); j++) tmp[i++] = buf[j];
57  for (j = 0 ; j < end ; j++) tmp[i++] = buf[j];
58  first = 0;
59  end = buf.size();
60  tmp.moveTo(buf);
61  }
62  }
int first
Definition: Queue.h:33
vec< T > buf
Definition: Queue.h:32
template<class T>
const T& Minisat::Queue< T >::operator[] ( int  index) const
inline

Definition at line 44 of file Queue.h.

44 { assert(index >= 0); assert(index < size()); return buf[(first + index) % buf.size()]; }
int first
Definition: Queue.h:33
int size() const
Definition: Queue.h:42
vec< T > buf
Definition: Queue.h:32
#define assert(ex)
Definition: util_old.h:213
template<class T>
T& Minisat::Queue< T >::operator[] ( int  index)
inline

Definition at line 45 of file Queue.h.

45 { assert(index >= 0); assert(index < size()); return buf[(first + index) % buf.size()]; }
int first
Definition: Queue.h:33
int size() const
Definition: Queue.h:42
vec< T > buf
Definition: Queue.h:32
#define assert(ex)
Definition: util_old.h:213
template<class T>
T Minisat::Queue< T >::peek ( ) const
inline

Definition at line 47 of file Queue.h.

47 { assert(first != end); return buf[first]; }
int first
Definition: Queue.h:33
vec< T > buf
Definition: Queue.h:32
#define assert(ex)
Definition: util_old.h:213
template<class T>
void Minisat::Queue< T >::pop ( )
inline

Definition at line 48 of file Queue.h.

48 { assert(first != end); first++; if (first == buf.size()) first = 0; }
int first
Definition: Queue.h:33
vec< T > buf
Definition: Queue.h:32
#define assert(ex)
Definition: util_old.h:213
template<class T>
int Minisat::Queue< T >::size ( ) const
inline

Definition at line 42 of file Queue.h.

42 { return (end >= first) ? end - first : end - first + buf.size(); }
int first
Definition: Queue.h:33
vec< T > buf
Definition: Queue.h:32

Field Documentation

template<class T>
vec<T> Minisat::Queue< T >::buf
private

Definition at line 32 of file Queue.h.

template<class T>
int Minisat::Queue< T >::end
private

Definition at line 34 of file Queue.h.

template<class T>
int Minisat::Queue< T >::first
private

Definition at line 33 of file Queue.h.


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