proxygen
Queue< E > Class Template Reference

#include <sample3-inl.h>

Public Member Functions

 Queue ()
 
 ~Queue ()
 
void Clear ()
 
size_t Size () const
 
QueueNode< E > * Head ()
 
const QueueNode< E > * Head () const
 
QueueNode< E > * Last ()
 
const QueueNode< E > * Last () const
 
void Enqueue (const E &element)
 
E * Dequeue ()
 
template<typename F >
QueueMap (F function) const
 
void push (const T &val)
 
void pop (T &val)
 
 Queue ()
 
 ~Queue ()
 
void Clear ()
 
size_t Size () const
 
QueueNode< E > * Head ()
 
const QueueNode< E > * Head () const
 
QueueNode< E > * Last ()
 
const QueueNode< E > * Last () const
 
void Enqueue (const E &element)
 
E * Dequeue ()
 
template<typename F >
QueueMap (F function) const
 
 Queue ()
 
 ~Queue ()
 
void Clear ()
 
size_t Size () const
 
QueueNode< E > * Head ()
 
const QueueNode< E > * Head () const
 
QueueNode< E > * Last ()
 
const QueueNode< E > * Last () const
 
void Enqueue (const E &element)
 
E * Dequeue ()
 
template<typename F >
QueueMap (F function) const
 

Private Member Functions

 Queue (const Queue &)
 
const Queueoperator= (const Queue &)
 
 Queue (const Queue &)
 
const Queueoperator= (const Queue &)
 
 Queue (const Queue &)
 
const Queueoperator= (const Queue &)
 

Private Attributes

QueueNode< E > * head_
 
QueueNode< E > * last_
 
size_t size_
 
std::queue< Tq_
 

Detailed Description

template<typename E>
class Queue< E >

Definition at line 44 of file sample3-inl.h.

Constructor & Destructor Documentation

template<typename E>
Queue< E >::Queue ( )
inline

Definition at line 77 of file sample3-inl.h.

77 : head_(NULL), last_(NULL), size_(0) {}
size_t size_
Definition: sample3-inl.h:165
QueueNode< E > * head_
Definition: sample3-inl.h:163
QueueNode< E > * last_
Definition: sample3-inl.h:164
template<typename E>
Queue< E >::~Queue ( )
inline

Definition at line 80 of file sample3-inl.h.

80 { Clear(); }
void Clear()
Definition: sample3-inl.h:83
template<typename E>
Queue< E >::Queue ( const Queue< E > &  )
private
template<typename E>
Queue< E >::Queue ( )
inline

Definition at line 77 of file sample3-inl.h.

77 : head_(NULL), last_(NULL), size_(0) {}
size_t size_
Definition: sample3-inl.h:165
QueueNode< E > * head_
Definition: sample3-inl.h:163
QueueNode< E > * last_
Definition: sample3-inl.h:164
template<typename E>
Queue< E >::~Queue ( )
inline

Definition at line 80 of file sample3-inl.h.

80 { Clear(); }
void Clear()
Definition: sample3-inl.h:83
template<typename E>
Queue< E >::Queue ( const Queue< E > &  )
private
template<typename E>
Queue< E >::Queue ( )
inline

Definition at line 77 of file sample3-inl.h.

77 : head_(NULL), last_(NULL), size_(0) {}
size_t size_
Definition: sample3-inl.h:165
QueueNode< E > * head_
Definition: sample3-inl.h:163
QueueNode< E > * last_
Definition: sample3-inl.h:164
template<typename E>
Queue< E >::~Queue ( )
inline

Definition at line 80 of file sample3-inl.h.

80 { Clear(); }
void Clear()
Definition: sample3-inl.h:83
template<typename E>
Queue< E >::Queue ( const Queue< E > &  )
private

Member Function Documentation

template<typename E>
void Queue< E >::Clear ( )
inline

Definition at line 83 of file sample3-inl.h.

83  {
84  if (size_ > 0) {
85  // 1. Deletes every node.
86  QueueNode<E>* node = head_;
87  QueueNode<E>* next = node->next();
88  for (; ;) {
89  delete node;
90  node = next;
91  if (node == NULL) break;
92  next = node->next();
93  }
94 
95  // 2. Resets the member variables.
96  head_ = last_ = NULL;
97  size_ = 0;
98  }
99  }
size_t size_
Definition: sample3-inl.h:165
QueueNode< E > * head_
Definition: sample3-inl.h:163
QueueNode< E > * last_
Definition: sample3-inl.h:164
QueueNode * next()
Definition: sample3-inl.h:57
def next(obj)
Definition: ast.py:58
template<typename E>
void Queue< E >::Clear ( )
inline

Definition at line 83 of file sample3-inl.h.

83  {
84  if (size_ > 0) {
85  // 1. Deletes every node.
86  QueueNode<E>* node = head_;
87  QueueNode<E>* next = node->next();
88  for (; ;) {
89  delete node;
90  node = next;
91  if (node == NULL) break;
92  next = node->next();
93  }
94 
95  // 2. Resets the member variables.
96  head_ = last_ = NULL;
97  size_ = 0;
98  }
99  }
size_t size_
Definition: sample3-inl.h:165
QueueNode< E > * head_
Definition: sample3-inl.h:163
QueueNode< E > * last_
Definition: sample3-inl.h:164
QueueNode * next()
Definition: sample3-inl.h:57
def next(obj)
Definition: ast.py:58
template<typename E>
void Queue< E >::Clear ( )
inline

Definition at line 83 of file sample3-inl.h.

83  {
84  if (size_ > 0) {
85  // 1. Deletes every node.
86  QueueNode<E>* node = head_;
87  QueueNode<E>* next = node->next();
88  for (; ;) {
89  delete node;
90  node = next;
91  if (node == NULL) break;
92  next = node->next();
93  }
94 
95  // 2. Resets the member variables.
96  head_ = last_ = NULL;
97  size_ = 0;
98  }
99  }
size_t size_
Definition: sample3-inl.h:165
QueueNode< E > * head_
Definition: sample3-inl.h:163
QueueNode< E > * last_
Definition: sample3-inl.h:164
QueueNode * next()
Definition: sample3-inl.h:57
def next(obj)
Definition: ast.py:58
template<typename E>
E* Queue< E >::Dequeue ( )
inline

Definition at line 131 of file sample3-inl.h.

Referenced by TEST_F().

131  {
132  if (size_ == 0) {
133  return NULL;
134  }
135 
136  const QueueNode<E>* const old_head = head_;
137  head_ = head_->next_;
138  size_--;
139  if (size_ == 0) {
140  last_ = NULL;
141  }
142 
143  E* element = new E(old_head->element());
144  delete old_head;
145 
146  return element;
147  }
size_t size_
Definition: sample3-inl.h:165
QueueNode< E > * head_
Definition: sample3-inl.h:163
QueueNode< E > * last_
Definition: sample3-inl.h:164
const E & element() const
Definition: sample3-inl.h:54
template<typename E>
E* Queue< E >::Dequeue ( )
inline

Definition at line 131 of file sample3-inl.h.

131  {
132  if (size_ == 0) {
133  return NULL;
134  }
135 
136  const QueueNode<E>* const old_head = head_;
137  head_ = head_->next_;
138  size_--;
139  if (size_ == 0) {
140  last_ = NULL;
141  }
142 
143  E* element = new E(old_head->element());
144  delete old_head;
145 
146  return element;
147  }
size_t size_
Definition: sample3-inl.h:165
QueueNode< E > * head_
Definition: sample3-inl.h:163
QueueNode< E > * last_
Definition: sample3-inl.h:164
const E & element() const
Definition: sample3-inl.h:54
template<typename E>
E* Queue< E >::Dequeue ( )
inline

Definition at line 131 of file sample3-inl.h.

131  {
132  if (size_ == 0) {
133  return NULL;
134  }
135 
136  const QueueNode<E>* const old_head = head_;
137  head_ = head_->next_;
138  size_--;
139  if (size_ == 0) {
140  last_ = NULL;
141  }
142 
143  E* element = new E(old_head->element());
144  delete old_head;
145 
146  return element;
147  }
size_t size_
Definition: sample3-inl.h:165
QueueNode< E > * head_
Definition: sample3-inl.h:163
QueueNode< E > * last_
Definition: sample3-inl.h:164
const E & element() const
Definition: sample3-inl.h:54
template<typename E>
void Queue< E >::Enqueue ( const E &  element)
inline

Definition at line 116 of file sample3-inl.h.

116  {
117  QueueNode<E>* new_node = new QueueNode<E>(element);
118 
119  if (size_ == 0) {
120  head_ = last_ = new_node;
121  size_ = 1;
122  } else {
123  last_->next_ = new_node;
124  last_ = new_node;
125  size_++;
126  }
127  }
size_t size_
Definition: sample3-inl.h:165
QueueNode< E > * head_
Definition: sample3-inl.h:163
QueueNode< E > * last_
Definition: sample3-inl.h:164
template<typename E>
void Queue< E >::Enqueue ( const E &  element)
inline

Definition at line 116 of file sample3-inl.h.

Referenced by Queue< int >::Map(), and QueueTest::SetUp().

116  {
117  QueueNode<E>* new_node = new QueueNode<E>(element);
118 
119  if (size_ == 0) {
120  head_ = last_ = new_node;
121  size_ = 1;
122  } else {
123  last_->next_ = new_node;
124  last_ = new_node;
125  size_++;
126  }
127  }
size_t size_
Definition: sample3-inl.h:165
QueueNode< E > * head_
Definition: sample3-inl.h:163
QueueNode< E > * last_
Definition: sample3-inl.h:164
template<typename E>
void Queue< E >::Enqueue ( const E &  element)
inline

Definition at line 116 of file sample3-inl.h.

116  {
117  QueueNode<E>* new_node = new QueueNode<E>(element);
118 
119  if (size_ == 0) {
120  head_ = last_ = new_node;
121  size_ = 1;
122  } else {
123  last_->next_ = new_node;
124  last_ = new_node;
125  size_++;
126  }
127  }
size_t size_
Definition: sample3-inl.h:165
QueueNode< E > * head_
Definition: sample3-inl.h:163
QueueNode< E > * last_
Definition: sample3-inl.h:164
template<typename E>
QueueNode<E>* Queue< E >::Head ( )
inline

Definition at line 105 of file sample3-inl.h.

105 { return head_; }
QueueNode< E > * head_
Definition: sample3-inl.h:163
template<typename E>
QueueNode<E>* Queue< E >::Head ( )
inline

Definition at line 105 of file sample3-inl.h.

Referenced by QueueTest::MapTester().

105 { return head_; }
QueueNode< E > * head_
Definition: sample3-inl.h:163
template<typename E>
QueueNode<E>* Queue< E >::Head ( )
inline

Definition at line 105 of file sample3-inl.h.

105 { return head_; }
QueueNode< E > * head_
Definition: sample3-inl.h:163
template<typename E>
const QueueNode<E>* Queue< E >::Head ( ) const
inline

Definition at line 106 of file sample3-inl.h.

106 { return head_; }
QueueNode< E > * head_
Definition: sample3-inl.h:163
template<typename E>
const QueueNode<E>* Queue< E >::Head ( ) const
inline

Definition at line 106 of file sample3-inl.h.

106 { return head_; }
QueueNode< E > * head_
Definition: sample3-inl.h:163
template<typename E>
const QueueNode<E>* Queue< E >::Head ( ) const
inline

Definition at line 106 of file sample3-inl.h.

106 { return head_; }
QueueNode< E > * head_
Definition: sample3-inl.h:163
template<typename E>
QueueNode<E>* Queue< E >::Last ( )
inline

Definition at line 109 of file sample3-inl.h.

109 { return last_; }
QueueNode< E > * last_
Definition: sample3-inl.h:164
template<typename E>
QueueNode<E>* Queue< E >::Last ( )
inline

Definition at line 109 of file sample3-inl.h.

109 { return last_; }
QueueNode< E > * last_
Definition: sample3-inl.h:164
template<typename E>
QueueNode<E>* Queue< E >::Last ( )
inline

Definition at line 109 of file sample3-inl.h.

109 { return last_; }
QueueNode< E > * last_
Definition: sample3-inl.h:164
template<typename E>
const QueueNode<E>* Queue< E >::Last ( ) const
inline

Definition at line 110 of file sample3-inl.h.

110 { return last_; }
QueueNode< E > * last_
Definition: sample3-inl.h:164
template<typename E>
const QueueNode<E>* Queue< E >::Last ( ) const
inline

Definition at line 110 of file sample3-inl.h.

110 { return last_; }
QueueNode< E > * last_
Definition: sample3-inl.h:164
template<typename E>
const QueueNode<E>* Queue< E >::Last ( ) const
inline

Definition at line 110 of file sample3-inl.h.

110 { return last_; }
QueueNode< E > * last_
Definition: sample3-inl.h:164
template<typename E>
template<typename F >
Queue* Queue< E >::Map ( function) const
inline

Definition at line 153 of file sample3-inl.h.

Referenced by QueueTest::MapTester().

153  {
154  Queue* new_queue = new Queue();
155  for (const QueueNode<E>* node = head_; node != NULL; node = node->next_) {
156  new_queue->Enqueue(function(node->element()));
157  }
158 
159  return new_queue;
160  }
Queue()
Definition: sample3-inl.h:77
QueueNode< E > * head_
Definition: sample3-inl.h:163
void Enqueue(const E &element)
Definition: sample3-inl.h:116
template<typename E>
template<typename F >
Queue* Queue< E >::Map ( function) const
inline

Definition at line 153 of file sample3-inl.h.

153  {
154  Queue* new_queue = new Queue();
155  for (const QueueNode<E>* node = head_; node != NULL; node = node->next_) {
156  new_queue->Enqueue(function(node->element()));
157  }
158 
159  return new_queue;
160  }
Queue()
Definition: sample3-inl.h:77
QueueNode< E > * head_
Definition: sample3-inl.h:163
void Enqueue(const E &element)
Definition: sample3-inl.h:116
template<typename E>
template<typename F >
Queue* Queue< E >::Map ( function) const
inline

Definition at line 153 of file sample3-inl.h.

153  {
154  Queue* new_queue = new Queue();
155  for (const QueueNode<E>* node = head_; node != NULL; node = node->next_) {
156  new_queue->Enqueue(function(node->element()));
157  }
158 
159  return new_queue;
160  }
Queue()
Definition: sample3-inl.h:77
QueueNode< E > * head_
Definition: sample3-inl.h:163
void Enqueue(const E &element)
Definition: sample3-inl.h:116
template<typename E>
const Queue& Queue< E >::operator= ( const Queue< E > &  )
private
template<typename E>
const Queue& Queue< E >::operator= ( const Queue< E > &  )
private
template<typename E>
const Queue& Queue< E >::operator= ( const Queue< E > &  )
private
template<typename E>
void Queue< E >::pop ( T val)
inline

Definition at line 838 of file RelaxedConcurrentPriorityQueueTest.cpp.

838  {
839  val = q_.front();
840  q_.pop();
841  }
double val
Definition: String.cpp:273
template<typename E>
void Queue< E >::push ( const T val)
inline

Definition at line 835 of file RelaxedConcurrentPriorityQueueTest.cpp.

835  {
836  q_.push(val);
837  }
double val
Definition: String.cpp:273
template<typename E>
size_t Queue< E >::Size ( ) const
inline

Definition at line 102 of file sample3-inl.h.

102 { return size_; }
size_t size_
Definition: sample3-inl.h:165
template<typename E>
size_t Queue< E >::Size ( ) const
inline

Definition at line 102 of file sample3-inl.h.

102 { return size_; }
size_t size_
Definition: sample3-inl.h:165
template<typename E>
size_t Queue< E >::Size ( ) const
inline

Definition at line 102 of file sample3-inl.h.

Referenced by QueueTest::MapTester(), and TEST_F().

102 { return size_; }
size_t size_
Definition: sample3-inl.h:165

Member Data Documentation

template<typename E>
QueueNode< E > * Queue< E >::head_
private

Definition at line 163 of file sample3-inl.h.

template<typename E>
QueueNode< E > * Queue< E >::last_
private

Definition at line 164 of file sample3-inl.h.

template<typename E>
std::queue<T> Queue< E >::q_
private

Definition at line 832 of file RelaxedConcurrentPriorityQueueTest.cpp.

template<typename E>
size_t Queue< E >::size_
private

Definition at line 165 of file sample3-inl.h.


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