#include "utypes.h"
#include <assert.h>
Namespaces | |
| namespace | ustl |
Defines | |
| #define | VectorSize(v) (sizeof(v) / sizeof(*v)) |
| Returns the number of elements in a static vector. | |
| #define | BitsInType(t) (sizeof(t) * CHAR_BIT) |
| Returns the number of bits in the given type. | |
| #define | BitMask(t, n) (t(~t(0)) >> ((sizeof(t) * CHAR_BIT) - (n))) |
Returns the mask of type t with the lowest n bits set. | |
| #define | DebugArg(x) x |
| Argument that is used only in debug builds (as in an assert). | |
| #define | foreach(type, i, ctr) for (type i = ctr.begin(); i != ctr.end(); ++ i) |
| Shorthand for container iteration. | |
| #define | eachfor(type, i, ctr) for (type i = ctr.rbegin(); i != ctr.rend(); ++ i) |
| Shorthand for container reverse iteration. | |
Functions | |
| 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> 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<typename T> 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> 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> 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. | |
Variables | |
| const size_t | c_DefaultAlignment = sizeof(void*) |
| The alignment performed by default. | |
Everything in here except min(), max(), distance(), and advance() are uSTL extensions and are absent from other STL implementations.