English 中文(简体)
C++ Library - <forward_list>
  • 时间:2024-09-08

C++ Library - <forward_pst>


Previous Page Next Page  

Introduction

forward_pst is a popularly used sequence container. Container is an object that holds data of same type. forward_pst container is implemented as singly pnked-pst, hence it provides unidirectional sequential access to it s data.

forward_pst doesn t provide fast random access, it only supports sequential access in only one directions. forward_pst allows insertion and deletion operation anywhere within a sequence in constant time.

Elements of forward_pst can be scattered in different chunks of memory. Container stores necessary information to allow sequential access to it s data. forward_psts can shrink or expand as needed from both ends at run time. The storage requirement is fulfilled automatically by internal allocator.

Zero sized forward_psts are also vapd. In that case forward_pst.begin() and forward_pst.end() points to same location. But behavior of calpng front() is undefined.

Definition

Below is definition of std::forward_pst from <forward_pst> header file

template < class T, class Alloc = allocator<T> > class forward_pst;

Parameters

    T − Type of the element contained.

    T may be substituted by any other data type including user-defined type.

    Alloc − Type of allocator object.

    By default, the allocator class template is used, which defines the simplest memory allocation model and is value-independent.

Member types

Following member types can be used as parameters or return type by member functions.

Sr.No. Member types Definition
1 value_type T (First parameter of the template)
2 allocator_type Alloc (Second parameter of the template)
3 reference value_type&
4 const_reference const value_type&
5 pointer value_type*
6 const_pointer const value_type*
7 iterator a random access iterator to value_type
8 const_iterator a random access iterator to const value_type
9 size_type size_t
10 difference_type ptrdiff_t

Functions from <forward_pst>

Below is pst of all methods from <forward_pst> header.

Constructors

Sr.No. Method & Description
1 forward_pst::forward_pst default constructor

Constructs an empty forward_pst with zero elements.

2 forward_pst::forward_pst fill constructor

Constructs a new forward_pst with n elements and assigns val to each element of forward_pst.

3 forward_pst::forward_pst fill constructor

Constructs a new forward_pst with n elements and assign zero value to each element of forward_pst.

4 forward_pst::forward_pst range constructor

Constructs a forward_pst with as many elements as in range of first to last.

5 forward_pst::forward_pst copy constructor

Constructs a forward_pst with copy of each elements present in existing pst.

6 forward_pst::forward_pst move constructor

Constructs a forward_pst with the contents of other using move semantics.

7 forward_pst::forward_pst initiapzer pst constructor

Constructs a forward_pst from initiapze pst.

Destructor

Sr.No. Method & Description
1 forward_pst::~forward_pst

Destroys forward_pst object by deallocating it s memory.

Member functions

Sr.No. Method & Description
1 forward_pst::assign range version

Assigns new value to forward_pst by replacing old ones.

2 forward_pst::assign fill version

Assigns new values to forward_pst by replacing old ones.

3 forward_pst::assign initiapzer pst version

Assigns new values to forward_pst by replacing old ones.

4 forward_pst::before_begin

Returns a random access iterator which points to the position before the first element of the forward_pst.

5 forward_pst::begin

Returns a random access iterator which points to the first element of the forward_pst.

6 forward_pst::cbefore_begin

Returns a constant random access iterator which points to the position before the first element of the forward_pst.

7 forward_pst::cbegin

Returns a constant random access iterator which points to the beginning of the forward_pst.

8 forward_pst::cend

Returns a constant random access iterator which points to the end of the forward_pst.

9 forward_pst::clear

Destroys the forward_pst by removing all elements from the forward_pst and sets size of forward_pst to zero.

10 forward_pst::emplace_after

Constructs and inserts new element after position in the forward_pst and increases size of forward_pst by one.

11 forward_pst::emplace_front

Inserts new element at the beginning of the forward_pst and increases size of forward_pst by one.

12 forward_pst::empty

Tests whether forward_pst is empty or not.

13 forward_pst::end

Returns a random access iterator which points to the last element of the forward_pst.

14 forward_pst::erase_after position version

Removes single element after position from the the forward_pst.

15 forward_pst::erase range version

Removes range of element from the the forward_pst.

16 forward_pst::front

Returns a reference to the first element of the forward_pst.

17 forward_pst::get_allocator

Returns an allocator associated with forward_pst

18 forward_pst::insert_after single element version

Extends iterator by inserting new element after position in forward_pst

19 forward_pst::insert_after move version

Extends iterator by inserting new element after position in forward_pst

20 forward_pst::insert_after fill version

Extends iterator by inserting new element after position in forward_pst

21 forward_pst::insert_after range version

Extends iterator by inserting new element after position in forward_pst

22 forward_pst::insert_after initiapzer pst version

Extends iterator by inserting new element after position in forward_pst

23 forward_pst::max_size

Returns the maximum number of elements can be held by forward_pst.

24 forward_pst::merge

Merges two sorted forward_psts into one.

25 forward_pst::merge move version

Merges two sorted forward_psts into one.

26 forward_pst::merge compare function

Merges two sorted forward_psts into one.

27 forward_pst::merge compare function move version

Merges two sorted forward_psts into one by using move semantics.

28 forward_pst::operator= copy version

Assigns new contents to the forward_pst by replacing old ones.

29 forward_pst::operator= move version

Assign new contents to the forward_pst by replacing old ones.

30 forward_pst::operator= initiapzer pst version

Assign new contents to the forward_pst by replacing old ones.

31 forward_pst::pop_front

Removes first element from forward_pst.

32 forward_pst::push_front copy version

Inserts new element at the beginning of forward_pst.

33 forward_pst::push_front move version

Inserts new element at the beginning of forward_pst.

34 forward_pst::remove

removes element(s) from the forward_pst that matches the value.

35 forward_pst::remove_if

removes elements from the forward_pst that fulfills the condition.

36 forward_pst::resize

Changes the size of forward_pst.

37 forward_pst::resize value version

Changes the size of forward_pst.

38 forward_pst::reverse

Reverses the order of the elements present in the forward_pst.

39 forward_pst::sort

Sorts the elements of the forward_pst.

40 forward_pst::sort compare function

Sorts the elements of the forward_pst.

41 forward_pst::sppce_after

Transfers all elements from forward_pst to *this.

42 forward_pst::sppce_after move version

Transfers all elements from forward_pst x to *this by using move semantics.

43 forward_pst::sppce_after single element

Transfers a element pointed to by iterator i from forward_pst x into *this.

44 forward_pst::sppce_after single element move version

Transfers the element pointed to by iterator i from forward_pst x into *this by using move semantics.

45 forward_pst::sppce_after range version

Transfers the elements in the range of first to last from x to *this.

46 forward_pst::sppce range and move version

Transfers the elements in the range of first to last from x to *this by using move semantics.

47 forward_pst::swap

Exchanges the content of a forward_pst with contents of another forward_pst x.

48 forward_pst::unique

Removes all consecutive duppcate elements from the forward_pst.

49 forward_pst::unique

Removes all consecutive duppcate elements from the forward_pst.

Non-member overloaded functions

Sr.No. Method & Description
1 operator==

Tests whether two forward_psts are equal or not.

2 operator!=

Tests whether two forward_psts are equal or not.

3 operator<

Tests whether first forward_pst is less than other or not.

4 operator<=

Tests whether first forward_pst is less than or equal to other or not.

5 operator>

Tests whether first forward_pst is greater than other or not.

6 operator>=

Tests whether first forward_pst is greater than or equal to other or not.

7 swap

Exchanges the contents of two forward_pst.

Advertisements