ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
Gluco2::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)
 

Detailed Description

template<class T>
class Gluco2::Queue< T >

Definition at line 33 of file Queue.h.

Member Typedef Documentation

◆ Key

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

Definition at line 39 of file Queue.h.

Constructor & Destructor Documentation

◆ Queue()

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

Definition at line 41 of file Queue.h.

41: buf(1), first(0), end(0) {}

Member Function Documentation

◆ clear()

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

Definition at line 43 of file Queue.h.

43{ buf.clear(dealloc); buf.growTo(1); first = end = 0; }

◆ insert()

template<class T>
void Gluco2::Queue< T >::insert ( T elem)
inline

Definition at line 51 of file Queue.h.

51 { // INVARIANT: buf[end] is always unused
52 buf[end++] = elem;
53 if (end == buf.size()) end = 0;
54 if (first == end){ // Resize:
55 vec<T> tmp((buf.size()*3 + 1) >> 1);
56 //**/printf("queue alloc: %d elems (%.1f MB)\n", tmp.size(), tmp.size() * sizeof(T) / 1000000.0);
57 int j, i = 0;
58 for (j = first; j < buf.size(); j++) tmp[i++] = buf[j];
59 for (j = 0 ; j < end ; j++) tmp[i++] = buf[j];
60 first = 0;
61 end = buf.size();
62 tmp.moveTo(buf);
63 }
64 }
int size() const
Definition Queue.h:44
Here is the call graph for this function:

◆ operator[]() [1/2]

template<class T>
T & Gluco2::Queue< T >::operator[] ( int index)
inline

Definition at line 47 of file Queue.h.

47{ assert(index >= 0); assert(index < size()); return buf[(first + index) % buf.size()]; }
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:

◆ operator[]() [2/2]

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

Definition at line 46 of file Queue.h.

46{ assert(index >= 0); assert(index < size()); return buf[(first + index) % buf.size()]; }
Here is the call graph for this function:

◆ peek()

template<class T>
T Gluco2::Queue< T >::peek ( ) const
inline

Definition at line 49 of file Queue.h.

49{ assert(first != end); return buf[first]; }

◆ pop()

template<class T>
void Gluco2::Queue< T >::pop ( )
inline

Definition at line 50 of file Queue.h.

50{ assert(first != end); first++; if (first == buf.size()) first = 0; }

◆ size()

template<class T>
int Gluco2::Queue< T >::size ( ) const
inline

Definition at line 44 of file Queue.h.

44{ return (end >= first) ? end - first : end - first + buf.size(); }
Here is the caller graph for this function:

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