/* * Copyright (C) 2007-2008 Xagasoft, All rights reserved. * * This file is part of the libbu++ library and is released under the * terms of the license contained in the file LICENSE. */ #ifndef BU_UTIL_H #define BU_UTIL_H /* I borrowed this from someone who borrowed it from glib who borrowed it * from... */ #if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) #define DEPRECATED __attribute__((__deprecated__)) #else #define DEPRECATED #endif /* __GNUC__ */ namespace Bu { template void swap( item &a, item &b ) { item tmp = a; a = b; b = tmp; } template const item &min( const item &a, const item &b ) { return a item &min( item &a, item &b ) { return a const item &max( const item &a, const item &b ) { return a>b?a:b; } template item &max( item &a, item &b ) { return a>b?a:b; } template const item &mid( const item &a, const item &b, const item &c ) { return min( max( a, b ), c ); } template item &mid( item &a, item &b, item &c ) { return min( max( a, b ), c ); } // // Basic comparison functors // template struct __basicLTCmp { bool operator()( const item &a, const item &b ) { return a < b; } }; template struct __basicGTCmp { bool operator()( const item &a, const item &b ) { return a > b; } }; template struct __basicPtrLTCmp { bool operator()( const item &a, const item &b ) { return *a < *b; } }; template struct __basicPtrGTCmp { bool operator()( const item &a, const item &b ) { return *a > *b; } }; }; #endif