Namespaces | Defines | Functions

_src_base_funcs_stl.hh File Reference

Helper functions for STL. More...

Go to the source code of this file.

Namespaces

namespace  base
 

Library of base code.


Defines

#define FOR_EACH(CONTAINER_TYPE, CONTAINER_VAR)   for ( CONTAINER_TYPE::iterator iter = CONTAINER_VAR.begin(); iter != CONTAINER_VAR.end(); ++iter )
#define RETURN_LT_TRUE_GT_FALSE(X, Y)

Functions

template<typename T >
T * base::PTR (std::vector< T > &v)
template<typename T >
const T * base::CONST_PTR (const std::vector< T > &v)
template<typename SEQCONT >
void base::Expand (SEQCONT &seqcont, uint idx)
template<typename CONTAINER >
bool base::Compare (const CONTAINER &c1, const CONTAINER &c2)
template<typename KEY >
bool base::Find (const std::list< KEY > &container, const KEY &key)
template<typename KEY >
bool base::Find (const std::vector< KEY > &container, const KEY &key)
template<typename KEY >
bool base::Find (const std::deque< KEY > &container, const KEY &key)
template<typename KEY >
bool base::Find (const std::set< KEY > &container, const KEY &key)
template<typename KEY , typename VAL >
bool base::Find (const std::map< KEY, VAL > &container, const KEY &key)
template<typename T >
void base::Remove (std::vector< T > &container, const T &item)
template<typename T >
void base::Remove (std::deque< T > &container, const T &item)
template<typename T >
void base::Remove (std::list< T > &container, const T &item)
template<typename KEY >
void base::Remove (std::set< KEY > &container, const KEY &item)
template<typename KEY , typename VAL >
void base::Remove (std::map< KEY, VAL > &container, const VAL &item)
template<typename CONTAINER >
bool base::IfDuplicate (const CONTAINER &c1, const CONTAINER &c2)

Detailed Description

Helper functions for STL.

LastChangedDate:
2011-04-23 21:07:07 -0400 (Sat, 23 Apr 2011)
Author:
Jim E. Brooks http://www.palomino3d.org

Define Documentation

#define FOR_EACH (   CONTAINER_TYPE,
  CONTAINER_VAR 
)    for ( CONTAINER_TYPE::iterator iter = CONTAINER_VAR.begin(); iter != CONTAINER_VAR.end(); ++iter )

A "for each" macro for a STL container. Recommended since a common typo is "<" or "==" instead of the correct "!=". Example: typedef vector<Object> Objects; FOR_EACH( Objects, mObjects ) { Object object = *iter; }

#define RETURN_LT_TRUE_GT_FALSE (   X,
  Y 
)
Value:
{{                                              \
    if ( (X) < (Y) ) return true;               \
    if ( (Y) < (X) ) return false;              \
}}

Helper for correctly writing operator<() for STL container. bool operator<( const C& a, const C& b ) { RETURN_LT_TRUE_GT_FALSE( a.x, b.x ) RETURN_LT_TRUE_GT_FALSE( a.y, b.y ) return false; // equal } "Effective C++" Item 21 says that a comparison function should return false for equal values or it will corrupt a set/map.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Palomino Flight Simulator documents generated by doxygen 1.7.1 on Tue May 15 2012 22:40:10