Skip to content

fill const_iterator

Ned Bingham edited this page Mar 11, 2017 · 7 revisions

std/fill.h


fill

  • struct const_iterator

Points to a location in a fill container.

Member Types

  • typedef value_type type so that generic wrappers can access the parent container's value_type

Member Variables

  • const fill<value_type> *root is a pointer to the parent container.
  • int index is the location that this iterator points to.

Member Functions

Constructor

const_iterator() The default constructor. root is set to NULL and index to 0.

const_iterator(const fill<value_type> *root, int index) This sets root and index directly. It's protected member that should only be used by the parent container.

Utility

operator bool() checks whether this iterator points to a valid position in the fill container.

Accessors

value_type operator*() returns this iterator's value.

const value_type *operator->() The dot operator for this iterator's value.

const value_type *ptr() returns a pointer to this iterator's value.

value_type get() returns this iterator's value.

const_iterator &ref() This is a placeholder function. It just returns the same iterator.

int idx() returns index.

Iteration

const_iterator &operator++() Increments the iterator to the next index value.

const_iterator &operator--() Decrements the iterator to the previous index value.

const_iterator &operator+=(int n) Increments the iterator by n.

const_iterator &operator-=(int n) Decrements the iterator by n.

const_iterator operator+(int n) Returns the iterator n elements ahead of this one.

const_iterator operator-(int n) Returns the iterator n elements behind this one.

Comparison

bool operator==(const_iterator i) Checks equality between iterators.

bool operator!=(const_iterator i) Checks inequality between iterators.

int operator-(const_iterator i) Returns the number of elements between i and this iterator.

Slicing

slice<range<const_iterator> > sub(int length)
fill<value_type> subcpy(int length)

Returns a slice or copy starting at this iterator with length length.

slice<range<const_iterator> > sub()
fill<value_type> subcpy()

Returns a slice or copy from this iterator to the end of the container.

Examples

#include <std/ascii_stream.h>
#include <std/fill.h>

using namespace core;

int main()
{
    fill<int> f(10, 5);
    for (fill<int>::iterator i = f.begin(); i != f.end(); i++)
        cout << i.idx() << ": " << *i << endl;
    return 0;
}
0: 5
1: 5
2: 5
3: 5
4: 5
5: 5
6: 5
7: 5
8: 5
9: 5

Simple Containers

Standard Containers

Interface Containers

Specialized Containers

Input/Output

Algorithm

Clone this wiki locally