树  0.1
数据结构_第6章
Queue::vecQueue< T > Class Template Reference

队头位置固定的队列类 More...

#include <vecQueue.hh>

Inheritance diagram for Queue::vecQueue< T >:
Collaboration diagram for Queue::vecQueue< T >:

Public Types

typedef T value_type
 类型别名定义 More...
 
typedef value_typereference
 数据的引用 More...
 
typedef size_t size_type
 计数器类型 More...
 
- Public Types inherited from Queue::Queue< T >
typedef T value_type
 类型别名定义 More...
 
typedef value_typereference
 数据的引用 More...
 
typedef size_t size_type
 计数器类型 More...
 

Public Member Functions

 vecQueue (size_type initSize=10)
 Construct a new vec Queue object. More...
 
virtual ~vecQueue ()
 Destroy the vec Queue object. More...
 
virtual bool isEmpty () const
 判队空 More...
 
virtual void enQueue (const_reference &x)
 入队一个元素 More...
 
virtual value_type deQueue ()
 出队一个元素 More...
 
virtual value_type getHead () const
 Get the Head object. More...
 
bool empty () const
 Test whether container is empty. More...
 
size_type size () const
 Returns the number of elements in the queue. More...
 
referencefront ()
 Returns a reference to the next element in the queue. More...
 
const_referencefront () const
 Returns a reference to the next element in the queue. More...
 
referenceback ()
 Returns a reference to the last element in the queue. More...
 
const_referenceback () const
 Returns a reference to the last element in the queue. More...
 
void push (const value_type &val)
 Inserts a new element at the end of the queue, after its current last element. More...
 
void push (value_type &&val)
 Inserts a new element at the end of the queue, after its current last element. More...
 
void pop ()
 Removes the next element in the queue. More...
 
- Public Member Functions inherited from Queue::Queue< T >
virtual void enQueue (const value_type &x)=0
 入队一个元素 More...
 
virtual ~Queue ()=default
 Destroy the Queue object. More...
 

Public Attributes

const typedef value_typeconst_reference
 数据的常量引用 More...
 
- Public Attributes inherited from Queue::Queue< T >
const typedef value_typeconst_reference
 数据的常量引用 More...
 

Private Member Functions

void doubleSpace ()
 扩大数组空间 More...
 

Private Attributes

size_type _maxSize
 内部数组的规模 More...
 
value_type_data
 存储队列的动态数组 More...
 
size_type _rear
 队尾下标 More...
 

Detailed Description

template<typename T>
class Queue::vecQueue< T >

队头位置固定的队列类

Template Parameters
T数据的类型

Definition at line 46 of file vecQueue.hh.

Member Typedef Documentation

◆ reference

template<typename T >
typedef value_type& Queue::vecQueue< T >::reference

数据的引用

Definition at line 68 of file vecQueue.hh.

◆ size_type

template<typename T >
typedef size_t Queue::vecQueue< T >::size_type

计数器类型

Definition at line 70 of file vecQueue.hh.

◆ value_type

template<typename T >
typedef T Queue::vecQueue< T >::value_type

类型别名定义

Note
测试:能否从基类继承 数据类型

Definition at line 67 of file vecQueue.hh.

Constructor & Destructor Documentation

◆ vecQueue()

template<class T >
Queue::vecQueue< T >::vecQueue ( size_type  initSize = 10)

Construct a new vec Queue object.

Parameters
initSize队列初始容量

Definition at line 211 of file vecQueue.hh.

◆ ~vecQueue()

template<class T >
Queue::vecQueue< T >::~vecQueue
virtual

Destroy the vec Queue object.

Definition at line 217 of file vecQueue.hh.

Member Function Documentation

◆ back() [1/2]

template<class T >
vecQueue< T >::const_reference & Queue::vecQueue< T >::back

Returns a reference to the last element in the queue.

Returns
reference& 队尾元素的引用

Definition at line 247 of file vecQueue.hh.

◆ back() [2/2]

template<typename T >
const_reference& Queue::vecQueue< T >::back ( ) const

Returns a reference to the last element in the queue.

Returns
const_reference& 队尾元素的常量引用

◆ deQueue()

template<typename T >
virtual value_type Queue::vecQueue< T >::deQueue ( )
inlinevirtual

出队一个元素

Returns
value_type 出队元素的值

Implements Queue::Queue< T >.

Definition at line 138 of file vecQueue.hh.

◆ doubleSpace()

template<class T >
void Queue::vecQueue< T >::doubleSpace
private

扩大数组空间

Definition at line 285 of file vecQueue.hh.

◆ empty()

template<class T >
bool Queue::vecQueue< T >::empty

Test whether container is empty.

Returns
true is empty
false not empty

Definition at line 223 of file vecQueue.hh.

◆ enQueue()

template<typename T >
virtual void Queue::vecQueue< T >::enQueue ( const_reference x)
inlinevirtual

入队一个元素

Parameters
x元素的数据

Definition at line 128 of file vecQueue.hh.

◆ front() [1/2]

template<class T >
vecQueue< T >::const_reference & Queue::vecQueue< T >::front

Returns a reference to the next element in the queue.

Returns
reference& 队首元素的引用

Definition at line 235 of file vecQueue.hh.

◆ front() [2/2]

template<typename T >
const_reference& Queue::vecQueue< T >::front ( ) const

Returns a reference to the next element in the queue.

Returns
const_reference& 队首元素的常量引用

◆ getHead()

template<typename T >
virtual value_type Queue::vecQueue< T >::getHead ( ) const
inlinevirtual

Get the Head object.

Returns
value_type 队首元素的值

Implements Queue::Queue< T >.

Definition at line 150 of file vecQueue.hh.

◆ isEmpty()

template<typename T >
virtual bool Queue::vecQueue< T >::isEmpty ( ) const
inlinevirtual

判队空

Returns
true 队空
false 队非空

Implements Queue::Queue< T >.

Definition at line 118 of file vecQueue.hh.

◆ pop()

template<class T >
void Queue::vecQueue< T >::pop

Removes the next element in the queue.

Note
effectively reducing its size by one.

Definition at line 277 of file vecQueue.hh.

◆ push() [1/2]

template<class T >
void Queue::vecQueue< T >::push ( const value_type val)

Inserts a new element at the end of the queue, after its current last element.

Parameters
val数据的值

Definition at line 259 of file vecQueue.hh.

◆ push() [2/2]

template<class T >
void Queue::vecQueue< T >::push ( value_type &&  val)

Inserts a new element at the end of the queue, after its current last element.

Parameters
val数据的值

Definition at line 268 of file vecQueue.hh.

◆ size()

template<class T >
vecQueue< T >::size_type Queue::vecQueue< T >::size

Returns the number of elements in the queue.

Returns
size_type the number of elements in the queue

Definition at line 229 of file vecQueue.hh.

Member Data Documentation

◆ _data

template<typename T >
value_type* Queue::vecQueue< T >::_data
private

存储队列的动态数组

Definition at line 82 of file vecQueue.hh.

◆ _maxSize

template<typename T >
size_type Queue::vecQueue< T >::_maxSize
private

内部数组的规模

Definition at line 76 of file vecQueue.hh.

◆ _rear

template<typename T >
size_type Queue::vecQueue< T >::_rear
private

队尾下标

Note
队头下标固定为0, 数据范围[0, _rear)

Definition at line 90 of file vecQueue.hh.

◆ const_reference

template<typename T >
const typedef value_type& Queue::vecQueue< T >::const_reference

数据的常量引用

Definition at line 69 of file vecQueue.hh.


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