Skip to content
Ned Bingham edited this page Mar 8, 2017 · 26 revisions

std/fill.h


template <class value_type> struct fill

Stores a counted number of duplicate elements.

Member Types

  • typedef value_type type so that generic wrappers can access this containers value_type
  • typedef const_iterator iterator so that algorithms dependent upon iterator work.
  • fill::const_iterator

Member Variables

  • value_type value represents the value of all of the elements stored.
  • int count represents the number of elements this container stores.

Member Functions

Constructor

Constructs a fill, initializing its contents depending on the constructor version used. There is no default constructor.

  • fill(int count, value_type value) sets count and value directly.
  • fill(const_iterator left, const_iterator right) where left and right demarcate the bounds of another fill container. This sets count to right-left and value to the value pointed to by left.

Utility

Basic functions necessary for algorithm execution.

  • int size() returns the value of count.

Iterators

  • const_iterator begin() returns an iterator to the first element.
  • const_iterator end() returns an iterator to one after the last element.
  • const_iterator rbegin() returns an iterator to the last element.
  • const_iterator rend() returns an iterator to one before the first element.
  • const_iterator at(int i) returns an iterator to the ith element.

Accessors

  • value_type front() returns value.
  • value_type back() returns value.
  • value_type get(int i) returns value.
  • value_type operator[](int i) returns value.

Slicing

  • slice<fill<value_type> > deref() wraps this fill with a slice. This is particularly useful if an algorithm gives you a container filled with iterators. You can convert it into a slice with a single call to this function.
  • slice<range<iterator> > sub(int start, int end) returns a slice of this container of the elements within the range [start,end).
  • slice<range<iterator> > sub(int start) returns a slice of this container of the elements after start.
  • slice<range<iterator> > sub() returns a slice of all the elements in this container.
  • static slice<range<const_iterator> > sub(const_iterator start, const_iterator end) returns a slice of all the elements within the range [start,end) of a fill container.
  • fill<value_type> subcpy(int start, int end) see above. This returns a copy instead of a slice.
  • fill<value_type> subcpy(int start) see above. This returns a copy instead of a slice.
  • fill<value_type> subcpy() see above. This returns a copy instead of a slice.
  • fill<typename container::iterator> sample(container &c) uses the values of the fill container as indices into c. Returns another fill container with the indexed value from c.
  • idx()

Modifiers

  • void swap(fill<value_type> &root) swaps the contents of this fill container with another.
  • fill<value_type> &operator=(const fill<value_type> &root) sets the contents of this fill container equal the contents of another.

Non-Member Functions

Comparison

Compares two fill containers by comparing value followed by count.

  • bool operator==(fill<value_type1> s1, fill<value_type2> s2)
  • bool operator!=(fill<value_type1> s1, fill<value_type2> s2)
  • bool operator<(fill<value_type1> s1, fill<value_type2> s2)
  • bool operator>(fill<value_type1> s1, fill<value_type2> s2)
  • bool operator<=(fill<value_type1> s1, fill<value_type2> s2)
  • bool operator>=(fill<value_type1> s1, fill<value_type2> s2)

Compares a fill container to a generic slice by calling compare().

  • bool operator==(fill<value_type1> s1, core::slice<container2> s2)
  • bool operator!=(fill<value_type1> s1, core::slice<container2> s2)
  • bool operator<(fill<value_type1> s1, core::slice<container2> s2)
  • bool operator>(fill<value_type1> s1, core::slice<container2> s2)
  • bool operator<=(fill<value_type1> s1, core::slice<container2> s2)
  • bool operator>=(fill<value_type1> s1, core::slice<container2> s2)
  • bool operator==(core::slice<container1> s1, fill<value_type2> s2)
  • bool operator!=(core::slice<container1> s1, fill<value_type2> s2)
  • bool operator<(core::slice<container1> s1, fill<value_type2> s2)
  • bool operator>(core::slice<container1> s1, fill<value_type2> s2)
  • bool operator<=(core::slice<container1> s1, fill<value_type2> s2)
  • bool operator>=(core::slice<container1> s1, fill<value_type2> s2)

Examples

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

using namespace core;

int main()
{
    fill<int> f(0, 10);
    cout << f << endl;
    return 0;
}

Simple Containers

Standard Containers

Interface Containers

Specialized Containers

Input/Output

Algorithm

Clone this wiki locally