View Template Library


reverse_view<Container, Const_tag, Base>

Category: adaptors

Component type: type

Description

The reverse_view presents the elements in the container in reverse order. The properties of any reverse_view instance depend on the properties of the container template parameter. The interface of reverse_view adapts itself to the referenced container, if this is one of Reversible Container, Random Access Container, Sequence.

Reversal is only applied in presenting the elements, the container's elements themselves are not altered.

The properties of the order of elements are the same as those provided by the underlying container, as is the validity of more than one active iterators at any one time.

A reverse_view owns its referenced container, if its base template parameter is aggregated_ownership, it merely references its container, if the base template parameter is referenced_ownership.

Template parameters

Parameter

Description

Default

container

The view's container type: a Reversible Container


const_tag

The view's const tag: either const_view_tag or mutable_view_tag

const_view_tag

base

The view's ownership type: the base class that determines if the view references or owns the container

referenced_ownership

Definition

Defined in the header reverse_view.hpp.

Model of

Single Container View

Type requirements

Container::value_type must have a operator*().


Container satisfies

View satisfies

Reversible Container

Reversible Container

Random Access Container

Random Access Container

Sequence

Sequence

Members

Member

Where defined

Description

value_type

Container

The type container::value_type of the elements accessed through the container.

domain_type

Single View

The type of the referenced container.

pointer

Container

container::pointer.

reference

Container

container::reference

const_reference

Container

container::const_reference

size_type

Container

container::size_type

difference_type

Container

container::difference_type

iterator

Reversible Container

Iterator used to iterate through the view.

const_iterator

Reversible Container

Const iterator used to iterate through the view.

reverse_iterator

Container

Iterator used to iterate backwards through a container.

const_reverse_iterator

Container

Const iterator used to iterate backwards through a container.

iterator begin()

Reversible Container

Valid for reversible container's only. Returns an iterator pointing to the begin of the view.

iterator end()

Reversible Container

Valid for reversible container's only. Returns an iterator pointing to the end of the view.

const_iterator begin() const

Reversible Container

Valid for reversible container's only. Returns a const_iterator pointing to the begin of the view.

const_iterator end() const

Reversible Container

Valid for reversible container's only. Returns a const_iterator pointing to the end of the view.

reverse_iterator rbegin()

Container

Returns a reverse_iterator pointing to the beginning of the reversed container.

reverse_iterator rend()

Container

Returns a reverse_iterator pointing to the end of the reversed container.

const_reverse_iterator rbegin() const

Container

Returns a const_reverse_iterator pointing to the beginning of the reversed container.

const_reverse_iterator rend() const

Container

Returns a const_reverse_iterator pointing to the end of the reversed container.

reference front()

Sequence

Returns a reference for the last element in the container. Only supported if container is a sequence.

reference back()

Sequence

Returns a reference for the first element in the container. Only supported if container is a sequence.

const_reference front() const

Sequence

Returns a const_reference for the last element in the container. Only supported if container is a sequence.

const_reference back() const

Sequence

Returns a const_reference for the first element in the container. Only supported if container is a sequence.

void pop_front()

Sequence

Call pop_back on the underlying container.

void pop_back()

Sequence

Call pop_front on the underlying container.

reference operator[](size_type n)

Random access container

Returns a reference for the (size() - (1 + n))th element in the container. Only supported if container is random access.

const_reference operator[](size_type n) const

Random access container

Returns a const_reference for the (size() - (1 + n))th element in the container. Only supported if container is random access.

reference at(size_type n)

Random access container

Returns a reference for the (size() - (1 + n))th element in the container. Only supported if container is random access. Does a range check on n and will throw std::range_error if it fails.

const_reference at(size_type n) const

Random access container

Returns a const_reference for the (size() - (1 + n))th element in the container. Only supported if container is random access. Does a range check on n and will throw std::range_error if it fails.

size_type size() const

Container

Returns the size of the view.

size_type max_size() const

Container

Returns the largest possible size of the view.

bool empty() const

Container

true if the view's size is 0.

reverse_view()

DefaultConstructible

Creates an empty view.

reverse_view(container_t&)

Assignable

Creates a view of given container.

void swap(reverse_view&)

Container

Swaps the two views. Iterators are invalidated by this operation. For referencing views, the containers themselves are not swapped.

bool operator==(const reverse_view&, const reverse_view&)

Forward Container

Tests two views for equality. This is a global function, not a member function. Views may be equal even if their referenced containers are not.

bool operator<(const reverse_view&, const reverse_view&)

Forward Container

Lexicographical comparison. This is a global function, not a member function.

Notes



VTL Home
Copyright © 1999 Konrad-Zuse-Zentrum für Informationstechnik Berlin & Gary Powell All Rights Reserved.