Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

ustl Namespace Reference

The ustl namespace contains all ustl classes and algorithms. More...


Classes

class  ustl::cmemlink
 A read-only pointer to a sized block of memory. More...
class  ustl::fdostringstream
 A string stream that writes to an fd. Implements cout and cerr. More...
class  ustl::fdistringstream
 A string stream that reads from an fd. Implements cin. More...
class  ustl::memblock
 Allocated memory block. More...
class  ustl::memlink
 Wrapper for pointer to block with size. More...
class  ustl::istream
 Helper class to read packed binary streams. More...
class  ustl::istream_iterator< T >
 An iterator over an istream to use with uSTL algorithms. More...
class  ustl::ostream
 Helper class to write packed binary streams. More...
class  ustl::ostream_iterator< T >
 An iterator over an ostream to use with uSTL algorithms. More...
class  ustl::istringstream
 A stream that reads textual data from a memory block. More...
class  ustl::ostringstream
 This stream writes textual data into a memory block. More...
class  ustl::bitset< Size >
 bitset is a fixed-size block of memory with addressable bits. More...
class  ustl::exception
 Base class for exceptions, equivalent to std::exception. More...
class  ustl::bad_cast
 Thrown to indicate a bad dynamic_cast usage. More...
class  ustl::bad_alloc
 Exception thrown on memory allocation failure by memblock::reserve. More...
class  ustl::libc_exception
 Thrown when a libc function returns an error. More...
class  ustl::file_exception
 File-related exceptions. More...
class  ustl::stream_bounds_exception
 Stream bounds checking. More...
struct  ustl::iterator_traits< Iterator >
 Contains the type traits of Iterator. More...
class  ustl::reverse_iterator< Iterator >
 Wraps Iterator to behave in an exactly opposite manner. More...
class  ustl::insert_iterator< Container >
 Calls insert on bound container for each assignment. More...
class  ustl::back_insert_iterator< Container >
 Calls push_back on bound container for each assignment. More...
class  ustl::index_iterate< RandomAccessIterator, IndexIterator >
 Allows iteration through an index container. More...
struct  ustl::numeric_limits< T >
 Defines numeric limits for a type. More...
class  ustl::list< T >
 Linked list emulator. More...
class  ustl::map< K, V >
 A sorted associative container of pair<K,V>. More...
class  ustl::matrix< NX, NY, T >
 A two-dimensional array of NX*NY elements of type T. More...
class  ustl::auto_ptr< T >
 A smart pointer. More...
class  ustl::multimap< K, V >
 A sorted associative container that may container multiple entries for each key. More...
class  ustl::multiset< T >
 Multiple sorted container. Unlike set, it may contain multiple copies of each element. More...
class  ustl::pair< T1, T2 >
 Container for two values. More...
class  ustl::queue< Sequence >
 Queue adapter to uSTL containers. More...
class  ustl::set< T >
 Unique sorted container. Sorted vector with all values unique. More...
struct  ustl::select1st< Pair >
 Takes a pair and returns pair.first This is an extension, available in uSTL and the SGI STL. More...
struct  ustl::select2nd< Pair >
 Takes a pair and returns pair.second This is an extension, available in uSTL and the SGI STL. More...
class  ustl::stack< Sequence >
 Stack adapter to uSTL containers. More...
class  ustl::logic_error
 Logic errors represent problems in the internal logic of the program. More...
class  ustl::domain_error
 Reports domain errors ("domain" is in the mathematical sense). More...
class  ustl::invalid_argument
 Reports an invalid argument to a function. More...
class  ustl::length_error
 Reports when an object exceeds its allowed size. More...
class  ustl::out_of_range
 Reports arguments with values out of allowed range. More...
class  ustl::runtime_error
 Reports errors that are dependent on the data being processed. More...
class  ustl::range_error
 Reports data that does not fall within the permitted range. More...
class  ustl::overflow_error
 Reports arithmetic overflow. More...
class  ustl::underflow_error
 Reports arithmetic underflow. More...
class  ustl::string
 STL basic_string equivalent. More...
class  ustl::utf8in_iterator< Iterator, WChar >
 An iterator adaptor to character containers for reading UTF-8 encoded text. More...
class  ustl::utf8out_iterator< Iterator, WChar >
 An iterator adaptor to character containers for writing UTF-8 encoded text. More...
class  ustl::tuple< N, T >
 A fixed-size array of N Ts. More...
class  ustl::vector< T >
 STL vector equivalent. More...

Typedefs

typedef uint32_t bitset_value_type
typedef uint32_t xfmt_t

Functions

template<>
size_t alignof (cmemlink)
istreamoperator>> (istream &is, memblock &l)
 Reads object l from stream is.
istreamoperator>> (istream &is, memlink &l)
 Reads object l from stream is.
template<typename T>
istreamoperator>> (istream &is, T *&v)
istreamoperator>> (istream &is, int8_t &v)
istreamoperator>> (istream &is, uint8_t &v)
istreamoperator>> (istream &is, int16_t &v)
istreamoperator>> (istream &is, uint16_t &v)
istreamoperator>> (istream &is, int32_t &v)
istreamoperator>> (istream &is, uint32_t &v)
istreamoperator>> (istream &is, float &v)
istreamoperator>> (istream &is, double &v)
istreamoperator>> (istream &is, wchar_t &v)
istreamoperator>> (istream &is, bool &v)
istreamoperator>> (istream &is, long &v)
istreamoperator>> (istream &is, unsigned long &v)
template<typename T>
ostreamoperator<< (ostream &os, T *v)
ostreamoperator<< (ostream &os, int8_t v)
ostreamoperator<< (ostream &os, uint8_t v)
ostreamoperator<< (ostream &os, int16_t v)
ostreamoperator<< (ostream &os, uint16_t v)
ostreamoperator<< (ostream &os, int32_t v)
ostreamoperator<< (ostream &os, uint32_t v)
ostreamoperator<< (ostream &os, float v)
ostreamoperator<< (ostream &os, double v)
ostreamoperator<< (ostream &os, wchar_t v)
ostreamoperator<< (ostream &os, bool v)
ostreamoperator<< (ostream &os, long v)
ostreamoperator<< (ostream &os, unsigned long v)
template<typename RealT, typename CastT>
void _cast_read (istringstream &is, RealT &v)
 Reads one type as another.
istringstreamoperator>> (istringstream &is, int8_t &v)
istringstreamoperator>> (istringstream &is, int32_t &v)
istringstreamoperator>> (istringstream &is, double &v)
istringstreamoperator>> (istringstream &is, bool &v)
istringstreamoperator>> (istringstream &is, wchar_t &v)
istringstreamoperator>> (istringstream &is, string &v)
template<typename T>
size_t stream_size_of (T *)
 Returns the size of the given object. Overloads for standard types are available.
size_t stream_size_of (int8_t)
size_t stream_size_of (uint8_t)
size_t stream_size_of (int16_t)
size_t stream_size_of (uint16_t)
size_t stream_size_of (int32_t)
size_t stream_size_of (uint32_t)
size_t stream_size_of (float)
size_t stream_size_of (double)
size_t stream_size_of (bool)
size_t stream_size_of (wchar_t)
size_t stream_size_of (long v)
size_t stream_size_of (unsigned long v)
template<typename ForwardIterator1, typename ForwardIterator2>
ForwardIterator2 swap_ranges (ForwardIterator1 first, ForwardIterator2 last, ForwardIterator2 result)
template<typename InputIterator, typename EqualityComparable>
InputIterator find (InputIterator first, InputIterator last, const EqualityComparable &value)
template<typename ForwardIterator>
ForwardIterator adjacent_find (ForwardIterator first, ForwardIterator last)
template<typename InputIterator>
pair< InputIterator, InputIterator > mismatch (InputIterator first1, InputIterator last1, InputIterator first2)
template<typename InputIterator>
bool equal (InputIterator first1, InputIterator last1, InputIterator first2)
 Returns true if two ranges are equal. This is an extension, present in uSTL and SGI STL.
template<typename InputIterator, typename EqualityComparable>
size_t count (InputIterator first, InputIterator last, const EqualityComparable &value)
template<typename InputIterator, typename OutputIterator, typename UnaryFunction>
OutputIterator transform (InputIterator first, InputIterator last, OutputIterator result, UnaryFunction op)
template<typename InputIterator1, typename InputIterator2, typename OutputIterator, typename BinaryFunction>
OutputIterator transform (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, OutputIterator result, BinaryFunction op)
template<typename ForwardIterator, typename T>
void replace (ForwardIterator first, ForwardIterator last, const T &old_value, const T &new_value)
template<typename InputIterator, typename OutputIterator, typename T>
OutputIterator replace_copy (InputIterator first, InputIterator last, OutputIterator result, const T &old_value, const T &new_value)
template<typename ForwardIterator, typename Generator>
void generate (ForwardIterator first, ForwardIterator last, Generator gen)
template<typename OutputIterator, typename Generator>
OutputIterator generate_n (OutputIterator first, size_t n, Generator gen)
template<typename BidirectionalIterator>
void reverse (BidirectionalIterator first, BidirectionalIterator last)
template<typename ForwardIterator>
ForwardIterator rotate (ForwardIterator first, ForwardIterator middle, ForwardIterator last)
template<typename InputIterator1, typename InputIterator2, typename OutputIterator>
OutputIterator merge (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result)
 Combines two sorted ranges.
template<typename InputIterator>
void inplace_merge (InputIterator first, InputIterator middle, InputIterator last)
template<typename InputIterator, typename OutputIterator, typename T>
OutputIterator remove_copy (InputIterator first, InputIterator last, OutputIterator result, const T &value)
template<typename InputIterator, typename OutputIterator, typename RInputIterator>
OutputIterator remove_copy (InputIterator first, InputIterator last, OutputIterator result, RInputIterator rfirst, RInputIterator rlast)
template<typename ForwardIterator, typename T>
ForwardIterator remove (ForwardIterator first, ForwardIterator last, const T &value)
template<typename InputIterator, typename OutputIterator>
OutputIterator unique_copy (InputIterator first, InputIterator last, OutputIterator result)
template<typename ForwardIterator>
ForwardIterator unique (ForwardIterator first, ForwardIterator last)
template<typename ForwardIterator, typename LessThanComparable>
ForwardIterator lower_bound (ForwardIterator first, ForwardIterator last, const LessThanComparable &value)
template<typename ForwardIterator, typename LessThanComparable>
ForwardIterator binary_search (ForwardIterator first, ForwardIterator last, const LessThanComparable &value)
template<typename ForwardIterator, typename LessThanComparable>
ForwardIterator upper_bound (ForwardIterator first, ForwardIterator last, const LessThanComparable &value)
template<typename ForwardIterator, typename LessThanComparable>
pair< ForwardIterator, ForwardIterator > equal_range (ForwardIterator first, ForwardIterator last, const LessThanComparable &value)
template<typename RandomAccessIterator>
void random_shuffle (RandomAccessIterator first, RandomAccessIterator last)
template<typename RandomAccessIterator, typename Compare>
void sort (RandomAccessIterator first, RandomAccessIterator last, Compare comp)
template<typename RandomAccessIterator>
void sort (RandomAccessIterator first, RandomAccessIterator last)
template<typename RandomAccessIterator>
void stable_sort (RandomAccessIterator first, RandomAccessIterator last)
template<typename RandomAccessIterator, typename Compare>
void stable_sort (RandomAccessIterator first, RandomAccessIterator last, Compare comp)
template<typename RandomAccessIterator>
void partial_sort (RandomAccessIterator first, RandomAccessIterator, RandomAccessIterator last)
 Partially sort the range. Postcondition is that middle has the nth element and [first, middle) has elements smaller than those in (middle, last). In this implementation, the entire array is sorted. I can't think of any use for it where the time gained would be useful.
template<typename RandomAccessIterator>
void nth_element (RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last)
 Puts nth element into its sorted position. In this implementation, the entire array is sorted. I can't think of any use for it where the time gained would be useful.
template<typename Assignable>
void swap (Assignable &a, Assignable &b)
template<typename Iterator>
void iterator_swap (Iterator a, Iterator b)
template<typename InputIterator, typename OutputIterator>
OutputIterator copy (InputIterator first, InputIterator last, OutputIterator result)
template<typename InputIterator, typename OutputIterator>
OutputIterator copy_n (InputIterator first, size_t count, OutputIterator result)
template<typename InputIterator, typename OutputIterator>
OutputIterator copy_backward (InputIterator first, InputIterator last, OutputIterator result)
 Copy copies elements from the range (last, first] to result.
template<typename InputIterator, typename UnaryFunction>
UnaryFunction for_each (InputIterator first, InputIterator last, UnaryFunction f)
template<typename ForwardIterator, typename T>
void fill (ForwardIterator first, ForwardIterator last, const T &value)
template<typename OutputIterator, typename T>
OutputIterator fill_n (OutputIterator first, size_t count, const T &value)
void convert_to_bitstring (const bitset_value_type *v, size_t n, string &buf)
void convert_from_bitstring (const string &buf, bitset_value_type *v, size_t n)
 Copies bits from buf as MSB "1011001..." LSB into v of size n.
template<typename Container, typename OutputIterator>
OutputIterator copy (const Container &ctr, OutputIterator result)
template<typename Container, typename OutputIterator, typename Predicate>
OutputIterator copy_if (Container &ctr, OutputIterator result, Predicate pred)
template<typename Container, typename UnaryFunction>
UnaryFunction for_each (Container &ctr, UnaryFunction f)
template<typename Container, typename UnaryFunction>
UnaryFunction for_each (const Container &ctr, UnaryFunction f)
template<typename Container, typename EqualityComparable>
Container::const_iterator find (const Container &ctr, const EqualityComparable &value)
template<typename Container, typename EqualityComparable>
Container::iterator find (Container &ctr, const EqualityComparable &value)
template<typename Container, typename Predicate>
Container::const_iterator find_if (const Container &ctr, Predicate pred)
template<typename Container, typename Predicate>
Container::iterator find_if (Container &ctr, Predicate pred)
template<typename Container, typename EqualityComparable>
size_t count (const Container &ctr, const EqualityComparable &value)
template<typename Container, typename Predicate>
size_t count_if (const Container &ctr, Predicate pred)
template<typename Container, typename UnaryFunction>
void transform (Container &ctr, UnaryFunction op)
template<typename Container, typename OutputIterator, typename UnaryFunction>
OutputIterator transform (Container &ctr, OutputIterator result, UnaryFunction op)
template<typename Container, typename InputIterator, typename OutputIterator, typename BinaryFunction>
OutputIterator transform (Container &ctr, InputIterator first, OutputIterator result, BinaryFunction op)
template<typename Container, typename T>
void replace (Container &ctr, const T &old_value, const T &new_value)
template<typename Container, typename Predicate, typename T>
void replace_if (Container &ctr, Predicate pred, const T &new_value)
template<typename Container, typename OutputIterator, typename T>
OutputIterator replace_copy (const Container &ctr, OutputIterator result, const T &old_value, const T &new_value)
template<typename Container, typename OutputIterator, typename Predicate, typename T>
OutputIterator replace_copy_if (const Container &ctr, OutputIterator result, Predicate pred, const T &new_value)
template<typename Container, typename T>
void fill (Container &ctr, const T &value)
template<typename Container, typename Generator>
void generate (Container &ctr, Generator gen)
template<typename Container>
void random_shuffle (Container &ctr)
template<typename Container, typename OutputIterator, typename T>
OutputIterator remove_copy (const Container &ctr, OutputIterator result, const T &value)
template<typename Container, typename OutputIterator, typename Predicate>
OutputIterator remove_copy_if (const Container &ctr, OutputIterator result, Predicate pred)
template<typename Container, typename T>
void remove (Container &ctr, const T &value)
template<typename Container, typename ForwardIterator>
void remove (Container &ctr, ForwardIterator rfirst, ForwardIterator rlast)
template<typename Container, typename Predicate>
void remove_if (Container &ctr, Predicate pred)
template<typename Container, typename OutputIterator>
OutputIterator unique_copy (const Container &ctr, OutputIterator result)
template<typename Container>
void unique (Container &ctr)
template<typename Container, typename BinaryPredicate>
void unique (Container &ctr, BinaryPredicate binary_pred)
template<typename Container>
void reverse (Container &ctr)
template<typename Container>
void rotate (Container &ctr, off_t offset)
template<typename Container, typename LessThanComparable>
Container::const_iterator lower_bound (const Container &ctr, const LessThanComparable &value)
template<typename Container, typename LessThanComparable>
Container::iterator lower_bound (Container &ctr, const LessThanComparable &value)
template<typename Container, typename LessThanComparable>
Container::const_iterator upper_bound (const Container &ctr, const LessThanComparable &value)
template<typename Container, typename LessThanComparable>
Container::iterator upper_bound (Container &ctr, const LessThanComparable &value)
template<typename Container>
Container::const_iterator binary_search (const Container &ctr, const typename Container::value_type &value)
template<typename Container>
Container::iterator binary_search (Container &ctr, const typename Container::value_type &value)
template<typename Container, typename LessThanComparable>
pair< typename Container::const_iterator,
typename Container::const_iterator > 
equal_range (const Container &ctr, const LessThanComparable &value)
template<typename Container, typename LessThanComparable>
pair< typename Container::iterator,
typename Container::iterator > 
equal_range (Container &ctr, const LessThanComparable &value)
template<typename Container>
void sort (Container &ctr)
template<typename Container, typename Compare>
void sort (Container &ctr, Compare comp)
template<typename Container>
void stable_sort (Container &ctr)
template<typename Container, typename Compare>
void stable_sort (Container &ctr, Compare comp)
template<typename Container>
Container::iterator unconst (typename Container::const_iterator i, Container &ctr)
template<typename Container1, typename Container2>
Container2::iterator ibyi (typename Container1::iterator idx, Container1 &ctr1, Container2 &ctr2)
 Converts a const_iterator in one container into a const_iterator in another container.
template<typename Arg, typename Result>
pointer_to_unary_function<
Arg, Result > 
ptr_fun (Result(*pfn)(Arg))
 ptr_fun(pfn) wraps function pointer pfn into a functor class that calls it.
template<class UnaryFunction>
unary_negate< UnaryFunction > unary_negator (UnaryFunction pfn)
 Returns the functor that negates the result of *pfn().
template<typename BinaryFunction>
binder1st< BinaryFunction > bind1st (BinaryFunction pfn, typename BinaryFunction::first_argument_type v)
 Converts pfn into a unary function by binding the first argument to v.
template<typename BinaryFunction>
binder2nd< BinaryFunction > bind2nd (BinaryFunction pfn, typename BinaryFunction::second_argument_type v)
 Converts pfn into a unary function by binding the second argument to v.
template<class T, typename VT>
const_mem_var1_t< binder2nd<
equal_to< VT > >, T, VT > 
mem_var_equal_to (const VT T::*mvp, const VT &v)
 Returned functor passes member variable mvp reference of given object to equal<VT>.
template<class T, typename VT>
const_mem_var1_t< binder2nd<
less< VT > >, T, VT > 
mem_var_less (const VT T::*mvp, const VT &v)
 Returned functor passes member variable mvp reference of given object to less<VT>.
template<class T, typename VT>
const_mem_var2_t< equal_to<
VT >, T, VT > 
mem_var_equal_to (const VT T::*mvp)
 Returned functor passes member variable mvp reference of given object to equal<VT>.
template<class T, typename VT>
const_mem_var2_t< less< VT >,
T, VT > 
mem_var_less (const VT T::*mvp)
 Returned functor passes member variable mvp reference of given object to less<VT>.
template<typename RandomAccessIterator, typename Compare>
void make_heap (RandomAccessIterator first, RandomAccessIterator last, Compare comp)
 make_heap turns the range [first, last) into a heap At completion, is_heap (first, last, comp) is true. The algorithm is adapted from "Classic Data Structures in C++" by Timothy Budd.
template<typename RandomAccessIterator, typename Compare>
void push_heap (RandomAccessIterator first, RandomAccessIterator last, Compare comp)
template<typename RandomAccessIterator>
void make_heap (RandomAccessIterator first, RandomAccessIterator last)
 Make_heap turns the range [first, last) into a heap At completion, is_heap (first, last) is true.
istreamoperator>> (istream &is, const ios::skip &op)
ostreamoperator<< (ostream &os, const ios::skip &op)
size_t stream_size_of (const ios::skip &op)
istreamoperator>> (istream &is, const ios::align &op)
ostreamoperator<< (ostream &os, const ios::align &op)
size_t stream_size_of (const ios::align &op)
ostringstreamoperator<< (ostringstream &os, const ios::width &op)
ostringstreamoperator<< (ostringstream &os, const ios::base &op)
template<class Container>
insert_iterator< Container > inserter (Container &ctr, typename Container::iterator ip)
 Returns the insert_iterator for ctr.
template<class Container>
back_insert_iterator< Container > back_inserter (Container &ctr)
 Returns the back_insert_iterator for ctr.
template<typename RandomAccessIterator, typename IndexIterator>
index_iterate< RandomAccessIterator,
IndexIterator > 
index_iterator (RandomAccessIterator ibase, IndexIterator iindex)
 Returns an index_iterate for ibase over iindex.
template<typename IndexContainer, typename IteratorContainer>
void indexv_to_iteratorv (typename IteratorContainer::value_type ibase, const IndexContainer &xc, IteratorContainer &ic)
 Converts the indexes in xc to iterators in ic of base ibase.
template<size_t NX, size_t NY, typename T>
void load_identity (matrix< NX, NY, T > &m)
template<size_t NX, size_t NY, typename T>
matrix< NY, NY, T > operator * (const matrix< NX, NY, T > &m1, const matrix< NY, NX, T > &m2)
template<size_t NX, size_t NY, typename T>
tuple< NX, T > operator * (const tuple< NY, T > &t, const matrix< NX, NY, T > &m)
template<size_t N, typename T>
void transpose (matrix< N, N, T > &m)
template<typename T>
void construct (T *p)
template<typename ForwardIterator>
void construct (ForwardIterator first, ForwardIterator last)
template<typename T>
void construct (T *p, const T &value)
template<typename T>
void destroy (T *p)
template<typename ForwardIterator>
void destroy (ForwardIterator first, ForwardIterator last)
template<typename T>
T * cast_to_type (void *p, const T *)
 Casts p to the type of the second pointer argument.
template<typename T>
pair< T *, ptrdiff_t > make_temporary_buffer (void *p, size_t n, const T *ptype)
 Creates a temporary buffer pair from p and n This is intended to be used with alloca to create temporary buffers. The size in the returned pair is set to 0 if the allocation is unsuccessful.
template<typename InputIterator, typename ForwardIterator>
ForwardIterator uninitialized_copy (InputIterator first, InputIterator last, ForwardIterator result)
template<typename InputIterator, typename ForwardIterator>
ForwardIterator uninitialized_copy_n (InputIterator first, size_t n, ForwardIterator result)
template<typename ForwardIterator, typename T>
void uninitialized_fill (ForwardIterator first, ForwardIterator last, const T &v)
template<typename ForwardIterator, typename T>
ForwardIterator uninitialized_fill_n (ForwardIterator first, size_t n, const T &v)
template<typename InputIterator, typename T>
accumulate (InputIterator first, InputIterator last, T init)
template<typename InputIterator, typename T, typename BinaryFunction>
accumulate (InputIterator first, InputIterator last, T init, BinaryFunction binary_op)
template<typename ForwardIterator, typename T>
void iota (ForwardIterator first, ForwardIterator last, T value)
template<typename InputIterator1, typename InputIterator2, typename T>
inner_product (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, T init)
template<typename InputIterator1, typename InputIterator2, typename T, typename BinaryOperation1, typename BinaryOperation2>
inner_product (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, T init, BinaryOperation1 sumOp, BinaryOperation2 productOp)
template<typename InputIterator, typename OutputIterator>
OutputIterator partial_sum (InputIterator first, InputIterator last, OutputIterator result)
template<typename InputIterator, typename OutputIterator, typename BinaryOperation>
OutputIterator partial_sum (InputIterator first, InputIterator last, OutputIterator result, BinaryOperation sumOp)
template<typename InputIterator, typename OutputIterator>
OutputIterator adjacent_difference (InputIterator first, InputIterator last, OutputIterator result)
template<typename InputIterator, typename OutputIterator, typename BinaryOperation>
OutputIterator adjacent_difference (InputIterator first, InputIterator last, OutputIterator result, BinaryOperation differenceOp)
template<typename T>
power (T x, unsigned n)
 Returns x^n. Donald Knuth's Russian Peasant algorithm.
template<typename T, typename BinaryOperation>
power (T x, unsigned n, BinaryOperation op)
 Returns x^n, using op instead of multiplication. Donald Knuth's Russian Peasant algorithm.
template<typename T1, typename T2>
bool operator== (const pair< T1, T2 > &p1, const pair< T1, T2 > &p2)
 Compares both values of p1 to those of p2.
template<typename T1, typename T2>
bool operator< (const pair< T1, T2 > &p1, const pair< T1, T2 > &p2)
 Compares both values of p1 to those of p2.
template<typename T1, typename T2>
pair< T1, T2 > make_pair (const T1 &a, const T2 &b)
 Returns a pair object with (a,b).
template<typename InputIterator, typename OutputIterator, typename Predicate>
OutputIterator copy_if (InputIterator first, InputIterator last, OutputIterator result, Predicate pred)
template<typename InputIterator, typename Predicate>
InputIterator find_if (InputIterator first, InputIterator last, Predicate pred)
template<typename ForwardIterator, typename BinaryPredicate>
ForwardIterator adjacent_find (ForwardIterator first, ForwardIterator last, BinaryPredicate p)
template<typename InputIterator, typename BinaryPredicate>
pair< InputIterator, InputIterator > mismatch (InputIterator first1, InputIterator last1, InputIterator first2, BinaryPredicate comp)
template<typename InputIterator, typename BinaryPredicate>
bool equal (InputIterator first1, InputIterator last1, InputIterator first2, BinaryPredicate comp)
template<typename InputIterator, typename Predicate>
size_t count_if (InputIterator first, InputIterator last, Predicate pred)
template<typename ForwardIterator, typename Predicate, typename T>
void replace_if (ForwardIterator first, ForwardIterator last, Predicate pred, const T &new_value)
template<typename InputIterator, typename OutputIterator, typename Predicate, typename T>
OutputIterator replace_copy_if (InputIterator first, InputIterator last, OutputIterator result, Predicate pred, const T &new_value)
template<typename InputIterator, typename OutputIterator, typename Predicate>
OutputIterator remove_copy_if (InputIterator first, InputIterator last, OutputIterator result, Predicate pred)
template<typename ForwardIterator, typename Predicate>
ForwardIterator remove_if (ForwardIterator first, ForwardIterator last, Predicate pred)
template<typename InputIterator, typename OutputIterator, typename BinaryPredicate>
OutputIterator unique_copy (InputIterator first, InputIterator last, OutputIterator result, BinaryPredicate binary_pred)
template<typename ForwardIterator, typename BinaryPredicate>
ForwardIterator unique (ForwardIterator first, ForwardIterator last, BinaryPredicate binary_pred)
template<typename ForwardIterator, typename T, typename StrictWeakOrdering>
ForwardIterator lower_bound (ForwardIterator first, ForwardIterator last, const T &value, StrictWeakOrdering comp)
template<typename ForwardIterator, typename T, typename StrictWeakOrdering>
ForwardIterator binary_search (ForwardIterator first, ForwardIterator last, const T &value, StrictWeakOrdering comp)
template<typename ForwardIterator, typename T, typename StrictWeakOrdering>
ForwardIterator upper_bound (ForwardIterator first, ForwardIterator last, const T &value, StrictWeakOrdering comp)
template<typename ForwardIterator, typename T, typename StrictWeakOrdering>
pair< ForwardIterator, ForwardIterator > equal_range (ForwardIterator first, ForwardIterator last, const T &value, StrictWeakOrdering comp)
template<typename RandomAccessIterator, typename Compare>
void nth_element (RandomAccessIterator first, RandomAccessIterator, RandomAccessIterator last, Compare comp)
 Puts nth element into its sorted position. In this implementation, the entire array is sorted. The performance difference is so small and the function use is so rare, there is no need to have code for it.
template<>
void swap (cmemlink &a, cmemlink &b)
template<>
void swap (memlink &a, memlink &b)
template<>
void swap (memblock &a, memblock &b)
template<>
void swap (string &a, string &b)
template<typename T>
void swap (vector< T > &a, vector< T > &b)
template<typename T>
void swap (set< T > &a, set< T > &b)
template<typename T>
void swap (multiset< T > &a, multiset< T > &b)
template<size_t N, typename T>
void swap (tuple< N, T > &a, tuple< N, T > &b)
template<typename Container>
size_t container_stream_size (const Container &v)
 Computes the stream size of a standard container.
template<typename T1, typename T2>
istreamoperator>> (istream &is, pair< T1, T2 > &p)
 Reads pair p from stream is.
template<typename T1, typename T2>
ostreamoperator<< (ostream &os, const pair< T1, T2 > &p)
 Writes pair p to stream os.
template<typename T1, typename T2>
ostringstreamoperator<< (ostringstream &os, const pair< T1, T2 > &p)
 Writes pair p to stream os.
template<typename T1, typename T2>
size_t stream_size_of (const pair< T1, T2 > &v)
 Returns the written size of the object.
template<typename Container>
pair< typename Container::iterator,
typename Container::iterator > 
unconst (const pair< typename Container::const_iterator, typename Container::const_iterator > &i, Container &ctr)
 Converts a const_iterator pair into an iterator pair Useful for converting pair ranges returned by equal_range, for instance. This is an extension, available in uSTL.
template<typename T>
istreamoperator>> (istream &is, vector< T > &v)
 Reads the vector from stream is.
template<typename T>
ostreamoperator<< (ostream &os, const vector< T > &v)
 Writes the vector to stream os.
template<typename T>
ostringstreamoperator<< (ostringstream &os, const vector< T > &v)
 Writes the vector to stream os.
template<typename T>
size_t stream_size_of (const vector< T > &v)
 Returns the number of bytes necessary to write this object to a stream.
template<size_t Size>
istreamoperator>> (istream &is, bitset< Size > &v)
 Reads bitset v from stream is.
template<size_t Size>
ostreamoperator<< (ostream &os, const bitset< Size > &v)
 Writes bitset v into stream os.
template<size_t Size>
ostringstreamoperator<< (ostringstream &os, const bitset< Size > &v)
 Writes bitset v into stream os.
template<size_t Size>
size_t stream_size_of (const bitset< Size > &v)
 Returns the number of bytes necessary to write this object to a stream.
template<size_t N, typename T>
istreamoperator>> (istream &is, tuple< N, T > &v)
 Reads tuple v from stream is.
template<size_t N, typename T>
ostreamoperator<< (ostream &os, const tuple< N, T > &v)
 Writes tuple v into stream os.
template<size_t N, typename T>
ostringstreamoperator<< (ostringstream &os, const tuple< N, T > &v)
 Writes tuple v into stream os.
template<size_t N>
ostringstreamoperator<< (ostringstream &os, const tuple< N, uint8_t > &v)
template<size_t N>
ostringstreamoperator<< (ostringstream &os, const tuple< N, int8_t > &v)
template<size_t N, typename T>
size_t stream_size_of (const tuple< N, T > &v)
 Returns the number of bytes necessary to write this object to a stream.
template<size_t NX, size_t NY, typename T>
ostringstreamoperator<< (ostringstream &os, const matrix< NX, NY, T > &v)
 Writes tuple v into stream os.
bool operator== (const char *s1, const string &s2)
 Returns true if s1 is equal to s2.
bool operator!= (const char *s1, const string &s2)
 Returns true if s1 is not equal to s2.
bool operator< (const char *s1, const string &s2)
 Returns true if s1 is equal to s2.
bool operator<= (const char *s1, const string &s2)
 Returns true if s1 is less than or equal to s2.
bool operator> (const char *s1, const string &s2)
 Returns true if s1 is equal to s2.
bool operator>= (const char *s1, const string &s2)
 Returns true if s1 is greater than or equal to s2.
template<>
size_t alignof (string)
template<typename T>
hashvalue_t hash_value (const T &v)
template<>
hashvalue_t hash_value (const string::const_pointer &v)
template<>
hashvalue_t hash_value (const string::pointer &v)
size_t Utf8Bytes (wchar_t v)
 Returns the number of bytes required to UTF-8 encode v.
size_t Utf8SequenceBytes (uint8_t c)
 Returns the number of bytes in a UTF-8 sequence that starts with c.
template<typename Iterator>
utf8out_iterator< Iterator > utf8out (Iterator i)
 Returns a UTF-8 adaptor writing to i. Useful in conjuction with back_insert_iterator.
template<typename Iterator>
utf8in_iterator< Iterator > utf8in (Iterator i)
 Returns a UTF-8 adaptor reading from i.
utf8in_iterator< istream_iterator<
uint8_t > > 
utf8in (istream &is)
 Returns a UTF-8 adaptor reading from is.
utf8out_iterator< ostream_iterator<
uint8_t > > 
utf8out (ostream &os)
 Returns a UTF-8 adaptor writing to os.
template<size_t N, typename T1, typename T2>
bool operator== (const tuple< N, T1 > &t1, const tuple< N, T2 > &t2)
template<size_t N, typename T1, typename T2>
bool operator< (const tuple< N, T1 > &t1, const tuple< N, T2 > &t2)
template<size_t N, typename T1, typename T2>
const tuple< N, T1 > & operator+= (tuple< N, T1 > &t1, const tuple< N, T2 > &t2)
template<size_t N, typename T1, typename T2>
const tuple< N, T1 > & operator-= (tuple< N, T1 > &t1, const tuple< N, T2 > &t2)
template<size_t N, typename T1, typename T2>
const tuple< N, T1 > & operator *= (tuple< N, T1 > &t1, const tuple< N, T2 > &t2)
template<size_t N, typename T1, typename T2>
const tuple< N, T1 > & operator/= (tuple< N, T1 > &t1, const tuple< N, T2 > &t2)
template<size_t N, typename T1, typename T2>
const tuple< N, T1 > operator+ (const tuple< N, T1 > &t1, const tuple< N, T2 > &t2)
template<size_t N, typename T1, typename T2>
const tuple< N, T1 > operator- (const tuple< N, T1 > &t1, const tuple< N, T2 > &t2)
template<size_t N, typename T1, typename T2>
const tuple< N, T1 > operator * (const tuple< N, T1 > &t1, const tuple< N, T2 > &t2)
template<size_t N, typename T1, typename T2>
const tuple< N, T1 > operator/ (const tuple< N, T1 > &t1, const tuple< N, T2 > &t2)
template<typename T1, typename T2>
const T1 min (const T1 &a, const T2 &b)
 Returns the minimum of a and b.
template<typename T1, typename T2>
const T1 max (const T1 &a, const T2 &b)
 Returns the maximum of a and b.
template<typename T1, typename T2>
T1 DivRU (T1 n1, T2 n2)
 Divides n1 by n2 and rounds the result up. This is in contrast to regular division, which rounds down. Negative numbers are rounded down because they are an unusual case, supporting which would require a branch. Since this is frequently used in graphics, the speed is important.
template<typename T>
Align (T n, T grain=c_DefaultAlignment)
 Rounds n up to be divisible by grain.
template<typename T>
size_t alignof (T)
 Returns the recommended alignment for type T.
template<>
size_t alignof (bool)
template<typename T>
advance (T i, ssize_t offset)
 Offsets an iterator.
template<typename T1, typename T2>
ptrdiff_t distance (T1 i1, T2 i2)
 Returns the difference p1 - p2.
template<typename T>
absv (T v)
 Returns the absolute value of v Unlike the stdlib functions, this is inline and works with all types.
template<typename T>
sign (T v)
 Returns -1 for negative values, 1 for positive, and 0 for 0.
template<typename T1, typename T2>
size_t abs_distance (T1 i1, T2 i2)
 Returns the absolute value of the distance i1 and i2.
template<typename T>
size_t size_of_elements (size_t n, const T *)
 Returns the size of n elements of size T.
template<typename T>
void Delete (T *&p)
 Template for for_each to call delete.
template<typename T>
void DeleteVector (T *&p)
 Template for for_each to call delete.
template<typename T>
bool operator!= (const T &x, const T &y)
 Template of making != from ! and ==.
template<typename T>
bool operator> (const T &x, const T &y)
 Template of making > from <.
template<typename T>
bool operator<= (const T &x, const T &y)
 Template of making <= from < and ==.
template<typename T>
bool operator>= (const T &x, const T &y)
 Template of making >= from < and ==.
template<typename TSmall, typename TBig>
void pack_type (TSmall s, TBig &b)
 Packs s multiple times into b. Useful for loop unrolling.
bool TestAndSet (int *pm)
 Sets the contents of pm to 1 and returns true if the previous value was 0.

Variables

fdistringstream cin (STDIN_FILENO)
fdostringstream cout (STDOUT_FILENO)
fdostringstream cerr (STDERR_FILENO)
const char endl = '\n'
 End of line character.
const char ends = '\0'
 End of string character.
const size_t c_DefaultAlignment = sizeof(void*)
 The alignment performed by default.


Detailed Description

The ustl namespace contains all ustl classes and algorithms.

Function Documentation

template<typename InputIterator, typename T, typename BinaryFunction>
T accumulate InputIterator  first,
InputIterator  last,
init,
BinaryFunction  binary_op
[inline]
 

Returns the sum of all elements in [first, last) via op, added to init.

template<typename InputIterator, typename T>
T accumulate InputIterator  first,
InputIterator  last,
init
[inline]
 

Returns the sum of all elements in [first, last) added to init.

template<typename InputIterator, typename OutputIterator, typename BinaryOperation>
OutputIterator adjacent_difference InputIterator  first,
InputIterator  last,
OutputIterator  result,
BinaryOperation  differenceOp
[inline]
 

Writes result such that result[i] = differenceOp (first[i], first[i - 1])

template<typename InputIterator, typename OutputIterator>
OutputIterator adjacent_difference InputIterator  first,
InputIterator  last,
OutputIterator  result
[inline]
 

Writes result such that result[i] = first[i] - first[i - 1]

template<typename ForwardIterator, typename BinaryPredicate>
ForwardIterator adjacent_find ForwardIterator  first,
ForwardIterator  last,
BinaryPredicate  p
[inline]
 

Returns the first iterator such that p(*i, *(i + 1)) == true.

template<typename ForwardIterator, typename T, typename StrictWeakOrdering>
ForwardIterator binary_search ForwardIterator  first,
ForwardIterator  last,
const T &  value,
StrictWeakOrdering  comp
[inline]
 

Performs a binary search inside the sorted range.

template<typename Container>
Container::const_iterator binary_search const Container &  ctr,
const typename Container::value_type &  value
[inline]
 

Performs a binary search for value. Assumes the range is sorted.

void ustl::convert_to_bitstring const bitset_value_type *  v,
size_t  n,
string &  buf
 

Copies bits from v of size n into buf as MSB "1011001..." LSB If buf is too small, MSB bits will be truncated.

template<typename Container, typename OutputIterator>
OutputIterator copy const Container &  ctr,
OutputIterator  result
[inline]
 

Copy copies elements from the range [first, last) to the range [result, result + (last - first)). That is, it performs the assignments result = *first, *(result + 1) = *(first + 1), and so on. [1] Generally, for every integer n from 0 to last - first, copy performs the assignment (result + n) = *(first + n). Assignments are performed in forward order, i.e. in order of increasing n.

template<typename InputIterator, typename OutputIterator, typename Predicate>
OutputIterator copy_if InputIterator  first,
InputIterator  last,
OutputIterator  result,
Predicate  pred
[inline]
 

Copy_if copies elements from the range [first, last) to the range [result, result + (last - first)) if pred(*i) returns true.

template<typename Container, typename OutputIterator, typename Predicate>
OutputIterator copy_if Container &  ctr,
OutputIterator  result,
Predicate  pred
[inline]
 

Copy_if copies elements from the range [first, last) to the range [result, result + (last - first)) if pred(*i) returns true.

template<typename Container, typename EqualityComparable>
size_t count const Container &  ctr,
const EqualityComparable &  value
[inline]
 

Count finds the number of elements in [first, last) that are equal to value. More precisely, the first version of count returns the number of iterators i in [first, last) such that *i == value.

template<typename InputIterator, typename Predicate>
size_t count_if InputIterator  first,
InputIterator  last,
Predicate  pred
[inline]
 

Count_if finds the number of elements in [first, last) that satisfy the predicate pred. More precisely, the first version of count_if returns the number of iterators i in [first, last) such that pred(*i) is true.

template<typename Container, typename Predicate>
size_t count_if const Container &  ctr,
Predicate  pred
[inline]
 

Count_if finds the number of elements in [first, last) that satisfy the predicate pred. More precisely, the first version of count_if returns the number of iterators i in [first, last) such that pred(*i) is true.

template<typename InputIterator, typename BinaryPredicate>
bool equal InputIterator  first1,
InputIterator  last1,
InputIterator  first2,
BinaryPredicate  comp
[inline]
 

Returns true if two ranges are equal. This is an extension, present in uSTL and SGI STL.

template<typename ForwardIterator, typename T, typename StrictWeakOrdering>
pair<ForwardIterator,ForwardIterator> equal_range ForwardIterator  first,
ForwardIterator  last,
const T &  value,
StrictWeakOrdering  comp
[inline]
 

Returns pair<lower_bound,upper_bound>

template<typename Container, typename LessThanComparable>
pair<typename Container::const_iterator,typename Container::const_iterator> equal_range const Container &  ctr,
const LessThanComparable &  value
[inline]
 

Returns pair<lower_bound,upper_bound>

template<typename Container, typename T>
void fill Container &  ctr,
const T &  value
[inline]
 

Fill assigns the value value to every element in the range [first, last). That is, for every iterator i in [first, last), it performs the assignment *i = value.

template<typename Container, typename EqualityComparable>
Container::const_iterator find const Container &  ctr,
const EqualityComparable &  value
[inline]
 

Returns the first iterator i in the range [first, last) such that i == value. Returns last if no such iterator exists.

template<typename InputIterator, typename Predicate>
InputIterator find_if InputIterator  first,
InputIterator  last,
Predicate  pred
[inline]
 

Returns the first iterator i in the range [first, last) such that pred(*i) is true. Returns last if no such iterator exists.

template<typename Container, typename Predicate>
Container::const_iterator find_if const Container &  ctr,
Predicate  pred
[inline]
 

Returns the first iterator i in the range [first, last) such that pred(*i) is true. Returns last if no such iterator exists.

template<typename Container, typename UnaryFunction>
UnaryFunction for_each const Container &  ctr,
UnaryFunction  f
[inline]
 

For_each applies the function object f to each element in the range [first, last); f's return value, if any, is ignored. Applications are performed in forward order, i.e. from first to last. For_each returns the function object after it has been applied to each element.

template<typename Container, typename UnaryFunction>
UnaryFunction for_each Container &  ctr,
UnaryFunction  f
[inline]
 

For_each applies the function object f to each element in the range [first, last); f's return value, if any, is ignored. Applications are performed in forward order, i.e. from first to last. For_each returns the function object after it has been applied to each element.

template<typename Container, typename Generator>
void generate Container &  ctr,
Generator  gen
[inline]
 

Generate assigns the result of invoking gen, a function object that takes no arguments, to each element in the range [first, last).

template<typename InputIterator1, typename InputIterator2, typename T, typename BinaryOperation1, typename BinaryOperation2>
T inner_product InputIterator1  first1,
InputIterator1  last1,
InputIterator2  first2,
init,
BinaryOperation1  sumOp,
BinaryOperation2  productOp
[inline]
 

Returns the sum of products of respective elements in the given ranges.

template<typename InputIterator1, typename InputIterator2, typename T>
T inner_product InputIterator1  first1,
InputIterator1  last1,
InputIterator2  first2,
init
[inline]
 

Returns the sum of products of respective elements in the given ranges.

template<typename ForwardIterator, typename T>
void iota ForwardIterator  first,
ForwardIterator  last,
value
[inline]
 

Assigns range [value, value + (last - first)) to [first, last)

template<typename ForwardIterator, typename T, typename StrictWeakOrdering>
ForwardIterator lower_bound ForwardIterator  first,
ForwardIterator  last,
const T &  value,
StrictWeakOrdering  comp
 

Returns the furthermost iterator i in [first, last) such that, for every iterator j in [first, i), comp(*j, value) is true. Assumes the range is sorted.

template<typename Container, typename LessThanComparable>
Container::const_iterator lower_bound const Container &  ctr,
const LessThanComparable &  value
[inline]
 

Returns the furthermost iterator i in [first, last) such that, for every iterator j in [first, i), *j < value Assumes the range is sorted.

template<typename InputIterator, typename BinaryPredicate>
pair<InputIterator,InputIterator> mismatch InputIterator  first1,
InputIterator  last1,
InputIterator  first2,
BinaryPredicate  comp
[inline]
 

Returns the pointer to the first pair of unequal elements.

template<typename InputIterator, typename OutputIterator, typename BinaryOperation>
OutputIterator partial_sum InputIterator  first,
InputIterator  last,
OutputIterator  result,
BinaryOperation  sumOp
[inline]
 

Writes result such that result[i] = sumOp (first...first+i)

template<typename InputIterator, typename OutputIterator>
OutputIterator partial_sum InputIterator  first,
InputIterator  last,
OutputIterator  result
[inline]
 

Writes result such that result[i] = sum (first...first+i)

template<typename Container, typename ForwardIterator>
void remove Container &  ctr,
ForwardIterator  rfirst,
ForwardIterator  rlast
[inline]
 

Remove removes from the range [first, last) all elements that have an iterator in range [rfirst, rlast). The range is assumed to be sorted. That is, remove returns an iterator new_last such that the range [first, new_last) contains no elements whose iterators are in [rfirst, rlast). Remove is stable, meaning that the relative order of elements that are not equal to value is unchanged. This version of the algorithm is a uSTL extension.

template<typename Container, typename T>
void remove Container &  ctr,
const T &  value
[inline]
 

Remove removes from the range [first, last) all elements that are equal to value. That is, remove returns an iterator new_last such that the range [first, new_last) contains no elements equal to value. Remove is stable, meaning that the relative order of elements that are not equal to value is unchanged.

template<typename Container, typename OutputIterator, typename T>
OutputIterator remove_copy const Container &  ctr,
OutputIterator  result,
const T &  value
[inline]
 

Remove_copy copies elements that are not equal to value from the range [first, last) to a range beginning at result. The return value is the end of the resulting range. This operation is stable, meaning that the relative order of the elements that are copied is the same as in the range [first, last).

template<typename InputIterator, typename OutputIterator, typename Predicate>
OutputIterator remove_copy_if InputIterator  first,
InputIterator  last,
OutputIterator  result,
Predicate  pred
[inline]
 

Remove_copy_if copies elements from the range [first, last) to a range beginning at result, except that elements for which pred is true are not copied. The return value is the end of the resulting range. This operation is stable, meaning that the relative order of the elements that are copied is the same as in the range [first, last).

template<typename Container, typename OutputIterator, typename Predicate>
OutputIterator remove_copy_if const Container &  ctr,
OutputIterator  result,
Predicate  pred
[inline]
 

Remove_copy_if copies elements from the range [first, last) to a range beginning at result, except that elements for which pred is true are not copied. The return value is the end of the resulting range. This operation is stable, meaning that the relative order of the elements that are copied is the same as in the range [first, last).

template<typename ForwardIterator, typename Predicate>
ForwardIterator remove_if ForwardIterator  first,
ForwardIterator  last,
Predicate  pred
[inline]
 

Remove_if removes from the range [first, last) every element x such that pred(x) is true. That is, remove_if returns an iterator new_last such that the range [first, new_last) contains no elements for which pred is true. The iterators in the range [new_last, last) are all still dereferenceable, but the elements that they point to are unspecified. Remove_if is stable, meaning that the relative order of elements that are not removed is unchanged.

template<typename Container, typename Predicate>
void remove_if Container &  ctr,
Predicate  pred
[inline]
 

Remove_if removes from the range [first, last) every element x such that pred(x) is true. That is, remove_if returns an iterator new_last such that the range [first, new_last) contains no elements for which pred is true. The iterators in the range [new_last, last) are all still dereferenceable, but the elements that they point to are unspecified. Remove_if is stable, meaning that the relative order of elements that are not removed is unchanged.

template<typename Container, typename T>
void replace Container &  ctr,
const T &  old_value,
const T &  new_value
[inline]
 

Replace replaces every element in the range [first, last) equal to old_value with new_value. That is: for every iterator i, if *i == old_value then it performs the assignment *i = new_value.

template<typename Container, typename OutputIterator, typename T>
OutputIterator replace_copy const Container &  ctr,
OutputIterator  result,
const T &  old_value,
const T &  new_value
[inline]
 

Replace_copy copies elements from the range [first, last) to the range [result, result + (last-first)), except that any element equal to old_value is not copied; new_value is copied instead. More precisely, for every integer n such that 0 <= n < last-first, replace_copy performs the assignment *(result+n) = new_value if *(first+n) == old_value, and (result+n) = *(first+n) otherwise.

template<typename InputIterator, typename OutputIterator, typename Predicate, typename T>
OutputIterator replace_copy_if InputIterator  first,
InputIterator  last,
OutputIterator  result,
Predicate  pred,
const T &  new_value
[inline]
 

Replace_copy_if copies elements from the range [first, last) to the range [result, result + (last-first)), except that any element for which pred is true is not copied; new_value is copied instead. More precisely, for every integer n such that 0 <= n < last-first, replace_copy_if performs the assignment *(result+n) = new_value if pred(*(first+n)), and *(result+n) = *(first+n) otherwise.

template<typename Container, typename OutputIterator, typename Predicate, typename T>
OutputIterator replace_copy_if const Container &  ctr,
OutputIterator  result,
Predicate  pred,
const T &  new_value
[inline]
 

Replace_copy_if copies elements from the range [first, last) to the range [result, result + (last-first)), except that any element for which pred is true is not copied; new_value is copied instead. More precisely, for every integer n such that 0 <= n < last-first, replace_copy_if performs the assignment *(result+n) = new_value if pred(*(first+n)), and *(result+n) = *(first+n) otherwise.

template<typename ForwardIterator, typename Predicate, typename T>
void replace_if ForwardIterator  first,
ForwardIterator  last,
Predicate  pred,
const T &  new_value
[inline]
 

Replace_if replaces every element in the range [first, last) for which pred returns true with new_value. That is: for every iterator i, if pred(*i) is true then it performs the assignment *i = new_value.

template<typename Container, typename Predicate, typename T>
void replace_if Container &  ctr,
Predicate  pred,
const T &  new_value
[inline]
 

Replace_if replaces every element in the range [first, last) for which pred returns true with new_value. That is: for every iterator i, if pred(*i) is true then it performs the assignment *i = new_value.

template<typename Container>
void reverse Container &  ctr  )  [inline]
 

Reverse reverses a range. That is: for every i such that 0 <= i <= (last - first) / 2), it exchanges *(first + i) and *(last - (i + 1)).

template<typename Container>
void rotate Container &  ctr,
off_t  offset
[inline]
 

Exchanges ranges [first, middle) and [middle, last)

template<typename Container, typename Compare>
void sort Container &  ctr,
Compare  comp
[inline]
 

Sorts the container

template<typename Container>
void sort Container &  ctr  )  [inline]
 

Sorts the container

template<typename Container, typename Compare>
void stable_sort Container &  ctr,
Compare  comp
[inline]
 

Sorts the container

template<typename Container>
void stable_sort Container &  ctr  )  [inline]
 

Sorts the container

template<typename Container, typename InputIterator, typename OutputIterator, typename BinaryFunction>
OutputIterator transform Container &  ctr,
InputIterator  first,
OutputIterator  result,
BinaryFunction  op
[inline]
 

The second version of transform is very similar, except that it uses a Binary Function instead of a Unary Function: it performs the operation op(*i1, *i2) for each iterator i1 in the range [first1, last1) and assigns the result to *o, where i2 is the corresponding iterator in the second input range and where o is the corresponding output iterator. That is, for each n such that 0 <= n < last1 - first1, it performs the assignment (result + n) = op(*(first1 + n), *(first2 + n). The return value is result + (last1 - first1).

template<typename Container, typename OutputIterator, typename UnaryFunction>
OutputIterator transform Container &  ctr,
OutputIterator  result,
UnaryFunction  op
[inline]
 

The first version of transform performs the operation op(*i) for each iterator i in the range [first, last), and assigns the result of that operation to *o, where o is the corresponding output iterator. That is, for each n such that 0 <= n < last - first, it performs the assignment (result + n) = op(*(first + n)). The return value is result + (last - first).

template<typename Container, typename UnaryFunction>
void transform Container &  ctr,
UnaryFunction  op
[inline]
 

The first version of transform performs the operation op(*i) for each iterator i in the range [first, last), and assigns the result of that operation to *o, where o is the corresponding output iterator. That is, for each n such that 0 <= n < last - first, it performs the assignment (result + n) = op(*(first + n)). The return value is result + (last - first).

template<typename Container>
Container::iterator unconst typename Container::const_iterator  i,
Container &  ctr
[inline]
 

Converts the given const_iterator into an iterator.

template<typename Container, typename BinaryPredicate>
void unique Container &  ctr,
BinaryPredicate  binary_pred
[inline]
 

Every time a consecutive group of duplicate elements appears in the range [first, last), the algorithm unique removes all but the first element. That is, unique returns an iterator new_last such that the range [first, new_last) contains no two consecutive elements that are duplicates. The iterators in the range [new_last, last) are all still dereferenceable, but the elements that they point to are unspecified. Unique is stable, meaning that the relative order of elements that are not removed is unchanged.

template<typename Container>
void unique Container &  ctr  )  [inline]
 

Every time a consecutive group of duplicate elements appears in the range [first, last), the algorithm unique removes all but the first element. That is, unique returns an iterator new_last such that the range [first, new_last) contains no two consecutive elements that are duplicates. The iterators in the range [new_last, last) are all still dereferenceable, but the elements that they point to are unspecified. Unique is stable, meaning that the relative order of elements that are not removed is unchanged.

template<typename Container, typename OutputIterator>
OutputIterator unique_copy const Container &  ctr,
OutputIterator  result
[inline]
 

Unique_copy copies elements from the range [first, last) to a range beginning with result, except that in a consecutive group of duplicate elements only the first one is copied. The return value is the end of the range to which the elements are copied. This behavior is similar to the Unix filter uniq.

template<typename ForwardIterator, typename T, typename StrictWeakOrdering>
ForwardIterator upper_bound ForwardIterator  first,
ForwardIterator  last,
const T &  value,
StrictWeakOrdering  comp
 

Returns the furthermost iterator i in [first,last) such that for every iterator j in [first,i), comp(value,*j) is false.

template<typename Container, typename LessThanComparable>
Container::const_iterator upper_bound const Container &  ctr,
const LessThanComparable &  value
[inline]
 

Returns the furthermost iterator i in [first,last) such that for every iterator j in [first,i), value < *j is false.


Generated on Mon Jan 17 14:35:02 2005 for uSTL by 1.3.9 Doxygen Hosted on SourceForge.net