View Template Library


flagged_filter_view<container, flags, const_tag, iter_tag, base_a,base_b>

Category: adaptors

Component type: type

Description

The flagged_filter_view template represents objects that reference one data container, and that have methods for accessing its elements. The properties of any flagged_filter_view instance depend on the properties of the container and flags template parameters.

The flagged_filter_view presents only those elements for which the corresponding flag in the flags container is true.

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

flagged_filter_views are mutable if and only if the const_tag template parameter is mutable_view_tag. Note that changing elements of the container may result in invalidated iterators. Thus, use mutable views only if you really know what you are doing.

A flagged_filter_view owns its referenced container/flags, if its base_a/base_b template parameter is aggregated_ownership, it merely references its container/flags, if the base_a/base_b template parameter is referenced_ownership.

Template parameters

Parameter

Description

Default

container

The view's container type: the type of container referenced by this view


flags

A parallel container used to filter the first container's elements


const_tag

The view's const tag: either const_view_tag or mutable_view_tag

const_view_tag

iterator_tag

The view's directional iterator category

Container::iterator::category or bidirectional_iterator_tag or flags::iterator::category, whichever is the lessest.

base_a

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

referenced_ownership

base_b

The view's flag ownership type: the tag class that determines if the view references or owns the flags.

referenced_ownership

Definition

Defined in the header flagged_filter_view.hpp.

Model of

Single Container View

This is debateable since actually two containers are used. Since only one of them is publically visible and use of a flag container instead of a predicate compared to filter_view is just an implementation detail (efficiency: you could use a predicate that looks up the values in a flag container), we feel that this must be a single container view.

Type requirements

T has to be assignable. flags has to be a container with a value type convertible to bool.

Members

Member

Where defined

Description

value_type

Container

The type T of the elements accessed through the container.

domain_type

Single View

The type of the referenced container.

pointer

Container

Pointer to T.

reference

Container

Reference to T.

const_reference

Container

Const reference to T.

size_type

Container

An unsigned integral type.

difference_type

Container

A signed integral type.

iterator

Container

Iterator used to iterate through the view.

const_iterator

Container

Const iterator used to iterate through the view.

reverse_iterator

Reversible Container

Iterator used to iterate backwards through a container.

const_reverse_iterator

Reversible Container

Const iterator used to iterate backwards through a container.

iterator begin()

Container

Returns an iterator pointing to the begin of the view.

iterator end()

Container

Returns an iterator pointing to the end of the view.

const_iterator begin() const

Container

Returns a const_iterator pointing to the begin of the view.

const_iterator end() const

Container

Returns a const_iterator pointing to the end of the view.

reverse_iterator rbegin()

Reversible Container

Valid for reversible container's only. Returns a reverse_iterator pointing to the beginning of the reversed container.

reverse_iterator rend()

Reversible Container

Valid for reversible container's only. Returns a reverse_iterator pointing to the end of the reversed container.

const_reverse_iterator rbegin() const

Reversible Container

Valid for reversible container's only. Returns a const_reverse_iterator pointing to the beginning of the reversed container.

const_reverse_iterator rend() const

Reversible Container

Valid for reversible container's only. Returns a const_reverse_iterator pointing to the end of the reversed container.

size_type size() const

Container

Returns the size of the view. [1]

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.

flagged_filter_view()

Default Constructible

The behaviour of default constructed views is undefined, except for subsequent assignment. This is only provided to satisfy the Default Constructible requirement.

flagged_filter_view(container_t&,flags const&)

view

Creates a view of given container. The size of the flags container must be equal or greater than the size of the data container.

void swap(flagged_filter_view&)

Container

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

bool operator==(const flagged_filter_view&, const flagged_filter_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 flagged_filter_view&, const flagged_filter_view&)

Forward Container

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

Notes

[1] A flagged_filter_view satisfies all the requirements of container, except for size() and iterator increment/decrement not guaranteeing constant complexity.


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