-
Notifications
You must be signed in to change notification settings - Fork 0
fill
template <class value_type> struct fill
Stores a counted number of duplicate elements.
-
typedef value_type type
so that generic wrappers can access this containersvalue_type
-
typedef const_iterator iterator
so that algorithms dependent upon iterator work. fill::<a href="fill-const_iterator>const_iterator
-
value_type value
represents the value of all of the elements stored. -
int count
represents the number of elements this container stores.
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
.
int size()
returns the value of count
.
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 i
th element.
value_type front()
returns value
.
value_type back()
returns value
.
value_type get(int i)
returns value
.
value_type operator[](int i)
returns value
.
slice<fill<value_type> > deref() ``` wraps this fill with a [slice](slice). This is particularly useful if an algorithm gives you a container filled with iterators. You can convert it into a [slice](slice) with a single call to this function. ```c++ fill idx() ``` If this container is filled with iterators, it returns the index of each iterator. ```c++ slice > sub(int start, int end) fill subcpy(int start, int end) ``` returns a [slice](slice) or copy of the elements within the range [`start`,`end`). ```c++ slice > sub(int start) fill subcpy(int start) ``` returns a [slice](slice) or copy of the elements after `start`. ```c++ slice > sub() fill subcpy() ``` returns a [slice](slice) or copy of all the elements in this container. ```c++ static slice > sub(const_iterator start, const_iterator end) ``` returns a [slice](slice) of all the elements within the range [`start`,`end`) of a fill container. ```c++ fill sample(container &c) fill sample(const container &c) ``` uses the values of the fill container as indices into `c`. Returns another fill container with the indexed value from `c`. ### Modifiers ```c++ void swap(fill &root) ``` swaps the contents of this fill container with another. ```c++ fill &operator=(const fill &root) ``` sets the contents of this fill container equal the contents of another. ## Non-Member Functions ### Comparison ```c++ bool operator==(fill s1, fill s2) bool operator!=(fill s1, fill s2) bool operator<(fill s1, fill s2) bool operator>(fill s1, fill s2) bool operator<=(fill s1, fill s2) bool operator>=(fill s1, fill s2) ``` Compares two fill containers by comparing `value` followed by `count`. ```c++ bool operator==(fill s1, core::slice s2) bool operator!=(fill s1, core::slice s2) bool operator<(fill s1, core::slice s2) bool operator>(fill s1, core::slice s2) bool operator<=(fill s1, core::slice s2) bool operator>=(fill s1, core::slice s2) bool operator==(core::slice s1, fill s2) bool operator!=(core::slice s1, fill s2) bool operator<(core::slice s1, fill s2) bool operator>(core::slice s1, fill s2) bool operator<=(core::slice s1, fill s2) bool operator>=(core::slice s1, fill s2) ``` Compares a fill container to a generic slice by calling `compare()`. ## Examples ```c++ #include #include using namespace core; int main() { fill f(10, 5); cout << f << endl; return 0; } ``` ``` {5, 5, 5, 5, 5, 5, 5, 5, 5, 5} ```