队列  0.1
数据结构_第4章
Queue::seqQueue< T > Class Template Referenceabstract

循环队列类 More...

#include <seqQueue.hh>

Inheritance diagram for Queue::seqQueue< T >:
[legend]
Collaboration diagram for Queue::seqQueue< T >:
[legend]

Public Types

typedef T value_type
 类型别名定义 More...
 
typedef value_typereference
 数据的引用 More...
 
typedef size_t size_type
 计数器类型 More...
 

Public Member Functions

 seqQueue (size_type initSize=10)
 Construct a new seq Queue object. More...
 
virtual ~seqQueue ()
 Destroy the seq 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, effectively reducing its size by one. More...
 
virtual void enQueue (const value_type &x)=0
 入队一个元素 More...
 

Public Attributes

const typedef value_typeconst_reference
 数据的常量引用 More...
 

Private Member Functions

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

Private Attributes

value_type_elem
 存储元素的内部数组 More...
 
size_type _maxSize
 数组的容量 More...
 
size_type _front
 队头/尾下标 数据范围(front, rear]: 在循环意义下 初始状态: front == rear == 0 队列满: front == (rear + 1) % maxSize 队列空: front == rear More...
 
size_type _rear
 

Detailed Description

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

循环队列类

Template Parameters
T数据的类型

Definition at line 46 of file seqQueue.hh.

Member Typedef Documentation

◆ reference

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

数据的引用

Definition at line 68 of file seqQueue.hh.

◆ size_type

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

计数器类型

Definition at line 70 of file seqQueue.hh.

◆ value_type

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

类型别名定义

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

Definition at line 67 of file seqQueue.hh.

Constructor & Destructor Documentation

◆ seqQueue()

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

Construct a new seq Queue object.

Parameters
initSize队列初始容量

Definition at line 216 of file seqQueue.hh.

◆ ~seqQueue()

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

Destroy the seq Queue object.

Definition at line 222 of file seqQueue.hh.

Member Function Documentation

◆ back() [1/2]

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

Returns a reference to the last element in the queue.

Returns
reference& 队尾元素的引用

Definition at line 252 of file seqQueue.hh.

◆ back() [2/2]

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

Returns a reference to the last element in the queue.

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

◆ deQueue()

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

出队一个元素

Returns
value_type

Implements Queue::Queue< T >.

Definition at line 143 of file seqQueue.hh.

Referenced by main().

Here is the caller graph for this function:

◆ doubleSpace()

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

扩大数组空间

Definition at line 288 of file seqQueue.hh.

◆ empty()

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

Test whether container is empty.

Returns
true is empty
false not empty

Definition at line 228 of file seqQueue.hh.

Referenced by main().

Here is the caller graph for this function:

◆ enQueue() [1/2]

template<typename T >
virtual void Queue::Queue< T >::enQueue ( const value_type x)
pure virtualinherited

入队一个元素

Parameters
x数据的值

◆ enQueue() [2/2]

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

入队一个元素

Parameters
x元素的数据

Definition at line 133 of file seqQueue.hh.

Referenced by main().

Here is the caller graph for this function:

◆ front() [1/2]

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

Returns a reference to the next element in the queue.

Returns
reference& 队首元素的引用

Definition at line 240 of file seqQueue.hh.

◆ front() [2/2]

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

Returns a reference to the next element in the queue.

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

◆ getHead()

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

Get the Head object.

Returns
value_type

Implements Queue::Queue< T >.

Definition at line 155 of file seqQueue.hh.

◆ isEmpty()

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

判队空

Returns
true 队空
false 队非空

Implements Queue::Queue< T >.

Definition at line 123 of file seqQueue.hh.

◆ pop()

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

Removes the next element in the queue, effectively reducing its size by one.

Definition at line 282 of file seqQueue.hh.

◆ push() [1/2]

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

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

Parameters
val数据的值

<

See also
seqQueue<T>::_maxSize

Definition at line 264 of file seqQueue.hh.

◆ push() [2/2]

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

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

Parameters
val数据的值

<

See also
seqQueue<T>::_maxSize

Definition at line 273 of file seqQueue.hh.

◆ size()

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

Returns the number of elements in the queue.

Returns
size_type the number of elements in the queue

Definition at line 234 of file seqQueue.hh.

Referenced by main().

Here is the caller graph for this function:

Member Data Documentation

◆ _elem

template<typename T >
value_type* Queue::seqQueue< T >::_elem
private

存储元素的内部数组

Definition at line 77 of file seqQueue.hh.

◆ _front

template<typename T >
size_type Queue::seqQueue< T >::_front
private

队头/尾下标 数据范围(front, rear]: 在循环意义下 初始状态: front == rear == 0 队列满: front == (rear + 1) % maxSize 队列空: front == rear

Definition at line 95 of file seqQueue.hh.

◆ _maxSize

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

数组的容量

Note
由于_elem[_front]规定为空, 故最多存储_maxSize - 1个元素

Definition at line 85 of file seqQueue.hh.

◆ _rear

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

Definition at line 95 of file seqQueue.hh.

◆ const_reference

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

数据的常量引用

Definition at line 69 of file seqQueue.hh.


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