优先级队列  0.1
数据结构_第7章
List::seqList< T > Class Template Reference

#include <seqList.h>

Inheritance diagram for List::seqList< T >:
Collaboration diagram for List::seqList< T >:

Classes

class  const_iterator
 
class  iterator
 

Public Member Functions

 seqList (size_t initSize=10)
 Construct a new seq List object. More...
 
 seqList (const seqList< T > &rhs)
 Construct a new seq List object. More...
 
 seqList (seqList< T > &&rvalue)
 Construct a new seq List object. More...
 
 seqList (const std::initializer_list< T > &init_list)
 Construct a new seq List object. More...
 
virtual ~seqList ()
 Destroy the seq List object. More...
 
virtual void clear ()
 
virtual int length () const
 
virtual void insert (int i, const T &obj)
 
virtual void remove (int i)
 
virtual int search (const T &obj) const
 
virtual T visit (int i) const
 
virtual void traverse (std::ostream &out=std::cout) const
 
T & operator[] (size_t index)
 下标访问(mutator) More...
 
const T & operator[] (size_t index) const
 下标访问(accessor) More...
 
void push_back (const T &x)
 在表尾插入新元素 More...
 
void push_back (T &&x)
 在表尾插入新元素 More...
 
void pop_back ()
 删除表尾元素 More...
 
size_t size () const
 返回线性表的当前元素个数,即长度 More...
 
size_t capacity () const noexcept
 Return size of allocated storage capacity. More...
 
T & front ()
 Access first element. More...
 
const T & front () const
 Access first element. More...
 
T & back ()
 Access last element. More...
 
const T & back () const
 Access last element. More...
 
void resize (size_t n)
 Change size Resizes the container so that it contains n elements. More...
 
void reserve (size_t n)
 Request a change in capacity. More...
 
virtual iterator begin ()
 
virtual const_iterator begin () const
 
virtual iterator end ()
 
virtual const_iterator end () const
 
- Public Member Functions inherited from List::List< T >
virtual ~List ()=default
 

Private Member Functions

void doubleSpace ()
 

Private Attributes

T * data
 
size_t currentLength
 
size_t maxSize
 

Friends

std::ostream & operator<< (std::ostream &out, const seqList &obj)
 将顺序表元素顺序插到输出流对象out中 More...
 

Detailed Description

template<typename T>
class List::seqList< T >

Definition at line 25 of file seqList.h.

Constructor & Destructor Documentation

◆ seqList() [1/4]

template<class T >
List::seqList< T >::seqList ( size_t  initSize = 10)

Construct a new seq List object.

Parameters
initSize初始容量

Definition at line 332 of file seqList.h.

◆ seqList() [2/4]

template<class T >
List::seqList< T >::seqList ( const seqList< T > &  rhs)

Construct a new seq List object.

Parameters
rhs复制源对象

Definition at line 360 of file seqList.h.

◆ seqList() [3/4]

template<class T >
List::seqList< T >::seqList ( seqList< T > &&  rvalue)

Construct a new seq List object.

Parameters
rvalue复制源对象

Definition at line 351 of file seqList.h.

◆ seqList() [4/4]

template<class T >
List::seqList< T >::seqList ( const std::initializer_list< T > &  init_list)

Construct a new seq List object.

Parameters
init_listbraced-init-list

Definition at line 339 of file seqList.h.

◆ ~seqList()

template<class T >
List::seqList< T >::~seqList
virtual

Destroy the seq List object.

Definition at line 292 of file seqList.h.

Member Function Documentation

◆ back() [1/2]

template<class T >
const T & List::seqList< T >::back

Access last element.

Returns a reference to the last element in the vector.

Returns
T& A reference to the last element in the vector. If the vector object is const-qualified, the function returns a const_reference. Otherwise, it returns a reference.

Definition at line 473 of file seqList.h.

◆ back() [2/2]

template<typename T >
const T& List::seqList< T >::back ( ) const

Access last element.

Returns a reference to the last element in the vector.

Returns
T& A reference to the last element in the vector. If the vector object is const-qualified, the function returns a const_reference. Otherwise, it returns a reference.

◆ begin() [1/2]

template<typename T >
virtual iterator List::seqList< T >::begin ( )
inlinevirtual

Definition at line 284 of file seqList.h.

◆ begin() [2/2]

template<typename T >
virtual const_iterator List::seqList< T >::begin ( ) const
inlinevirtual

Definition at line 285 of file seqList.h.

◆ capacity()

template<class T >
size_t List::seqList< T >::capacity
noexcept

Return size of allocated storage capacity.

Returns the size of the storage space currently allocated for the vector, expressed in terms of elements. This capacity is not necessarily equal to the vector size. It can be equal or greater, with the extra space allowing to accommodate for growth without the need to reallocate on each insertion.
Notice that this capacity does not suppose a limit on the size of the vector. When this capacity is exhausted and more is needed, it is automatically expanded by the container (reallocating it storage space).

Returns
size_t The size of the currently allocated storage capacity in the vector, measured in terms of the number elements it can hold.

Member type size_type is an unsigned integral type.

Definition at line 494 of file seqList.h.

◆ clear()

template<class T >
void List::seqList< T >::clear
virtual

Implements List::List< T >.

Definition at line 298 of file seqList.h.

Referenced by Queue::BinaryHeap< int, std::greater< int > >::clear().

Here is the caller graph for this function:

◆ doubleSpace()

template<class T >
void List::seqList< T >::doubleSpace
private

Definition at line 378 of file seqList.h.

◆ end() [1/2]

template<typename T >
virtual iterator List::seqList< T >::end ( )
inlinevirtual

Definition at line 286 of file seqList.h.

◆ end() [2/2]

template<typename T >
virtual const_iterator List::seqList< T >::end ( ) const
inlinevirtual

Definition at line 287 of file seqList.h.

◆ front() [1/2]

template<class T >
const T & List::seqList< T >::front

Access first element.

Returns a reference to the first element in the vector.

Returns
T& A reference to the first element in the vector container. If the vector object is const-qualified, the function returns a const_reference. Otherwise, it returns a reference.

Definition at line 461 of file seqList.h.

◆ front() [2/2]

template<typename T >
const T& List::seqList< T >::front ( ) const

Access first element.

Returns a reference to the first element in the vector.

Returns
T& A reference to the first element in the vector container. If the vector object is const-qualified, the function returns a const_reference. Otherwise, it returns a reference.

◆ insert()

template<class T >
void List::seqList< T >::insert ( int  i,
const T &  obj 
)
virtual

Implements List::List< T >.

Definition at line 389 of file seqList.h.

Referenced by List::operator+().

Here is the caller graph for this function:

◆ length()

template<class T >
int List::seqList< T >::length
virtual

Implements List::List< T >.

Definition at line 304 of file seqList.h.

Referenced by List::operator+().

Here is the caller graph for this function:

◆ operator[]() [1/2]

template<class T >
T & List::seqList< T >::operator[] ( size_t  index)

下标访问(mutator)

Parameters
index下标
Returns
T& 元素

Definition at line 423 of file seqList.h.

◆ operator[]() [2/2]

template<class T >
const T & List::seqList< T >::operator[] ( size_t  index) const

下标访问(accessor)

Parameters
index下标
Returns
const T& 元素

Definition at line 431 of file seqList.h.

◆ pop_back()

template<class T >
void List::seqList< T >::pop_back

删除表尾元素

Definition at line 455 of file seqList.h.

Referenced by Queue::BinaryHeap< int, std::greater< int > >::pop().

Here is the caller graph for this function:

◆ push_back() [1/2]

template<class T >
void List::seqList< T >::push_back ( const T &  x)

在表尾插入新元素

Parameters
x新元素

Definition at line 439 of file seqList.h.

Referenced by main(), and Queue::BinaryHeap< int, std::greater< int > >::push().

Here is the caller graph for this function:

◆ push_back() [2/2]

template<class T >
void List::seqList< T >::push_back ( T &&  x)

在表尾插入新元素

Parameters
x新元素

Definition at line 447 of file seqList.h.

◆ remove()

template<class T >
void List::seqList< T >::remove ( int  i)
virtual

Implements List::List< T >.

Definition at line 401 of file seqList.h.

◆ reserve()

template<class T >
void List::seqList< T >::reserve ( size_t  n)

Request a change in capacity.

Requests that the vector capacity be at least enough to contain n elements. If n is greater than the current vector capacity, the function causes the container to reallocate its storage increasing its capacity to n (or greater).\ In all other cases, the function call does not cause a reallocation and the vector capacity is not affected.\ This function has no effect on the vector size and cannot alter its elements.\

Parameters
nMinimum capacity for the vector.\ Note that the resulting vector capacity may be equal or greater than n.\ Member type size_type is an unsigned integral type.

Definition at line 500 of file seqList.h.

◆ resize()

template<class T >
void List::seqList< T >::resize ( size_t  n)

Change size Resizes the container so that it contains n elements.

Parameters
nNew container size, expressed in number of elements.

Definition at line 485 of file seqList.h.

◆ search()

template<class T >
int List::seqList< T >::search ( const T &  obj) const
virtual

Implements List::List< T >.

Definition at line 368 of file seqList.h.

◆ size()

template<class T >
size_t List::seqList< T >::size

返回线性表的当前元素个数,即长度

Returns
size_t 当前线性表长,即元素个数

Definition at line 310 of file seqList.h.

Referenced by Queue::BinaryHeap< int, std::greater< int > >::BinaryHeap(), and Queue::BinaryHeap< int, std::greater< int > >::size().

Here is the caller graph for this function:

◆ traverse()

template<class T >
void List::seqList< T >::traverse ( std::ostream &  out = std::cout) const
virtual

Definition at line 322 of file seqList.h.

Referenced by main().

Here is the caller graph for this function:

◆ visit()

template<class T >
T List::seqList< T >::visit ( int  i) const
virtual

Implements List::List< T >.

Definition at line 316 of file seqList.h.

Referenced by List::operator+().

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ operator<<

template<typename T >
std::ostream& operator<< ( std::ostream &  out,
const seqList< T > &  obj 
)
friend

将顺序表元素顺序插到输出流对象out中

Parameters
out输出流对象,可以是std::cout,或fout等
obj顺序表对象
Returns
std::ostream& 实参输出流对象的引用

Definition at line 278 of file seqList.h.

Member Data Documentation

◆ currentLength

template<typename T >
size_t List::seqList< T >::currentLength
private

Definition at line 29 of file seqList.h.

Referenced by List::seqList< value_type >::end().

◆ data

template<typename T >
T* List::seqList< T >::data
private

◆ maxSize

template<typename T >
size_t List::seqList< T >::maxSize
private

Definition at line 30 of file seqList.h.

Referenced by List::seqList< value_type >::seqList().


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