iterator3bobcat
Iterator returning plain values when dereferenced fbb::reverseiterator - reverse_iterator for fbb::iterator
Usage
#include <bobcat/iterator>
Overview
The FBB::Iterator<Type> class template implements a bidirectional iterator for plain data types. Dereferencing FBB::Iterator objects returns values of type Type, e.g., char or int. This iterator comes in handy in case you need to initialize an objects with a range of values, which are of some basic type (see also the EXAMPLE section).
FBB::ReverseIterator implements a reverse iterator for FBB::Iterator.
Namespace
FBB
All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the namespace FBB.
Inherits from
std::iterator<std::bidirectional_iterator_tag, ...>
Constructors
Constructors for Iterator<Type>:
- o
-
explicit Iterator(Tye const &value):
This constructor initializes theIteratorobject with an initial Type value. When dereferencing this iterator, value is returned.
The Iterator<Type>’s default, copy, and move constructors (and its copy and move assignment operators) are available.
Constructors for ReverseIterator<Type>:
- o
-
explicit ReverseIterator(Type const &value):
This constructor initializes theReverseIteratorobject with an initial Type value. When dereferencing this iterator immediately following its construction, the decremented value is returned (without modifying the internally stored Type value);
- o
-
explicit ReverseIterator(Iterator<Type> const &iter):
This constructor initializes theReverseIteratorobject with an initial Iterator<Type> object. When dereferencing this iterator immediately following its construction, the decrementedIterator’s value is returned (without modifying the Type value that is stored inside theIterator).
The ReverseIterator<Type>’s default, copy, and move constructors (and its copy and move assignment operators) are available.
Member functions
For template parameter type Type all members of std::iterator<std:::reverse_iterator_tag, Type> are available, as FBB::Iterator and FBB::ReverseIterator inherit from this class.
- o
-
Iterator<Type> &operator++():
The (prefix) increment operator increments the iterator’s value and returns a reference to itself;
- o
-
Iterator<Type> &operator++(int):
The (postfix) increment operator increments the iterator’s value and returns a copy of itself, initialized with the iterator’s value before it was incremented;
- o
-
Iterator<Type> &operator--():
The (prefix) decrement operator decrements the iterator’s value and returns a reference to itself;
- o
-
Iterator<Type> &operator--(int):
The (postfix) decrement operator decrements the iterator’s value and returns a copy of itself, initialized with the iterator’s value before it was decremented;
- o
-
bool operator==(Iterator<Type> const &rhs) const:
This operator returns true if the value of the currentIteratorobject is equal to the value of the rhsIteratorobject;
- o
-
bool operator!=(Iterator<Type> const &rhs) const:
This operator returns true if the value of the currentIteratorobject is not equal to the value of the rhsIteratorobject;
- o
-
Type &operator*():
The derefence operator returns a reference to theIterator’s value.
- o
-
Type const &operator*() const:
This derefence operator returns a reference to theIterator’s immutable value.
Static member functions
Static members of Iterator<Type>:
- o
-
Iterator<Type> last(Type value):
AnIterator<Type>object is returned initialized with ++value, so it can be conveniently be used to create an inclusive iterator range (see also section EXAMPLE);
- o
-
Iterator<Type> max():
AnIterator<Type>object is returned initialized with the value returned by std::numeric_limits<Type>::max();
- o
-
Iterator<Type> min():
AnIterator<Type>object is returned initialized with the value returned by std::numeric_limits<Type>::min()
Static member of ReverseIterator<Type>:
- o
-
ReverseIterator<Type> last(Type const &value):
AReverseIterator<Type>object is returned initialized withIterator<Type>::last(value), so it can be conveniently be used to create an inclusive reverse iterator range (see also section EXAMPLE);
Examples
#include <algorithm>
#include <iterator>
#include <iostream>
#include <string>
#include <bobcat/iterator>
using namespace std;
using namespace FBB;
int main()
{
copy(Iterator<int>(10), Iterator<int>(20),
ostream_iterator<int>(cout, ", "));
cout << ’\n’;
copy(Iterator<char>(*Iterator<char>::max() - 9),
Iterator<char>::last(*Iterator<char>::max()),
ostream_iterator<int>(cout, ", "));
cout << ’\n’;
cout << *Iterator<int>::max() << ’\n’;
copy(Iterator<int>(*Iterator<int>::max() - 9),
Iterator<int>::last(*Iterator<int>::max()),
ostream_iterator<int>(cout, ", "));
cout << ’\n’;
copy(ReverseIterator<int>(20), ReverseIterator<int>(10),
ostream_iterator<int>(cout, ", "));
cout << ’\n’;
std::string letters(Iterator<char>(’a’), Iterator<char>::last(’z’));
cout << letters << ’\n’;
std::string caps(ReverseIterator<char>::last(’Z’),
ReverseIterator<char>(’A’));
cout << caps << ’\n’;
}
Files
bobcat/iterator - defines the class interface
Bobcat project files
- o
-
https://fbb-git.gitlab.io/bobcat/: gitlab project page;
Debian Bobcat project files:
- o
-
libbobcat6: debian package containing the shared library, changelog and copyright note;
- o
-
libbobcat-dev: debian package containing the static library, headers, manual pages, and developer info;
Bobcat
Bobcat is an acronym of `Brokken’s Own Base Classes And Templates’.
Releases
6 releases since Debian 8 (Jessie); the text changed 5 times.