-
Notifications
You must be signed in to change notification settings - Fork 0
range
template <class value_type> struct range
Stores a range of values in [start,finish) traversed via addition operators.
-
typedef value_type type
so that generic wrappers can access this containersvalue_type
-
typedef const_iterator iterator
so that algorithms dependent upon iterator work. - range::const_iterator
-
value_type start
represents the starting value of the range. -
value_type finish
represents the ending value of the range.
The default constructor.
Set start
and finish
directly.
Copy another range of any type into this one with implicit type casts.
Copy another range using it's iterator bounds (this is used by the sub() functions).
Basic functions necessary for algorithm execution.
returns the number of values in this range: finish-start
.
returns an iterator to the first element.
returns an iterator to one after the last element.
returns an iterator to the last element.
returns an iterator to one before the first element.
returns an iterator to the i
th element.
returns value
.
returns value
.
returns value
.
returns value
.
wraps this range 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.
This is orthogonal to deref()
. If this container is filled with iterators, it returns the index of each iterator.
returns a slice of this container of the elements within the range [start
,end
).
returns a slice of this container of the elements after start
.
returns a slice of all the elements in this container.
returns a slice of all the elements within the range [start
,end
) of a range container.
see above. This returns a copy instead of a slice.
see above. This returns a copy instead of a slice.
see above. This returns a copy instead of a slice.
uses the values of the range container as indices into c
. Returns another range container with the indexed value from c
.
swaps the contents of this range container with another.
sets the contents of this range container equal the contents of another.
bool operator==(range<value_type1> s1, range<value_type2> s2)
bool operator!=(range<value_type1> s1, range<value_type2> s2)
bool operator<(range<value_type1> s1, range<value_type2> s2)
bool operator>(range<value_type1> s1, range<value_type2> s2)
bool operator<=(range<value_type1> s1, range<value_type2> s2)
bool operator>=(range<value_type1> s1, range<value_type2> s2)
Compares two range containers by comparing start
followed by finish
.
bool operator==(range<value_type1> s1, core::slice<container2> s2)
bool operator!=(range<value_type1> s1, core::slice<container2> s2)
bool operator<(range<value_type1> s1, core::slice<container2> s2)
bool operator>(range<value_type1> s1, core::slice<container2> s2)
bool operator<=(range<value_type1> s1, core::slice<container2> s2)
bool operator>=(range<value_type1> s1, core::slice<container2> s2)
bool operator==(core::slice<container1> s1, range<value_type2> s2)
bool operator!=(core::slice<container1> s1, range<value_type2> s2)
bool operator<(core::slice<container1> s1, range<value_type2> s2)
bool operator>(core::slice<container1> s1, range<value_type2> s2)
bool operator<=(core::slice<container1> s1, range<value_type2> s2)
bool operator>=(core::slice<container1> s1, range<value_type2> s2)
Compares a range container to a generic slice by calling compare()
.
#include <std/ascii_stream.h>
#include <std/slice.h>
using namespace core;
int main()
{
range<int> f(3, 8);
cout << f << endl;
return 0;
}
{3, 4, 5, 6, 7}