/usr/include/stxxl/bits/common
NameSizeModeActions
addressable_queues.h60360644editdlrm
aligned_alloc.h53870644editdlrm
binary_buffer.h200630644editdlrm
cmdline.h234820644editdlrm
condition_variable.h21410644editdlrm
counting_ptr.h164040644editdlrm
error_handling.h77020644editdlrm
exceptions.h20000644editdlrm
exithandler.h14000644editdlrm
external_shared_ptr.h37600644editdlrm
is_sorted.h18180644editdlrm
log.h12650644editdlrm
mutex.h33320644editdlrm
new_alloc.h39010644editdlrm
onoff_switch.h21460644editdlrm
rand.h81910644editdlrm
seed.h8630644editdlrm
semaphore.h24490644editdlrm
settings.h9710644editdlrm
simple_vector.h46390644editdlrm
state.h16870644editdlrm
timer.h46620644editdlrm
tmeta.h29880644editdlrm
tuple.h195530644editdlrm
types.h19230644editdlrm
uint_types.h95720644editdlrm
utils.h83800644editdlrm
Edit: /usr/include/stxxl/bits/common/tuple.h (19553B)
/*************************************************************************** * include/stxxl/bits/common/tuple.h * * Part of the STXXL. See http://stxxl.sourceforge.net * * Copyright (C) 2003 Roman Dementiev * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) **************************************************************************/ #ifndef STXXL_COMMON_TUPLE_HEADER #define STXXL_COMMON_TUPLE_HEADER #include #include #include #include STXXL_BEGIN_NAMESPACE struct Plug { }; template struct tuple_base { typedef T1 first_type; typedef T2 second_type; typedef T3 third_type; typedef T4 fourth_type; typedef T5 fifth_type; typedef T6 sixth_type; template struct item_type { /* typedef typename SWITCH > > > > > > >::result result; */ }; }; //! k-Tuple data type //! //! (defined for k < 7) template struct tuple { //! First tuple component type typedef T1 first_type; //! Second tuple component type typedef T2 second_type; //! Third tuple component type typedef T3 third_type; //! Fourth tuple component type typedef T4 fourth_type; //! Fifth tuple component type typedef T5 fifth_type; //! Sixth tuple component type typedef T6 sixth_type; template struct item_type { typedef typename SWITCH > > > > > > >::result result; }; //! First tuple component first_type first; //! Second tuple component second_type second; //! Third tuple component third_type third; //! Fourth tuple component fourth_type fourth; //! Fifth tuple component fifth_type fifth; //! Sixth tuple component sixth_type sixth; //! Empty constructor tuple() { } //! Construct tuple from components tuple(first_type _first, second_type _second, third_type _third, fourth_type _fourth, fifth_type _fifth, sixth_type _sixth ) : first(_first), second(_second), third(_third), fourth(_fourth), fifth(_fifth), sixth(_sixth) { } //! Equality comparison bool operator == (const tuple& t) const { return first == t.first && second == t.second && third == t.third && fourth == t.fourth && fifth == t.fifth && sixth == t.sixth; } //! Inequality comparison bool operator != (const tuple& t) const { return !(first == t.first && second == t.second && third == t.third && fourth == t.fourth && fifth == t.fifth && sixth == t.sixth); } //! Make tuple ostream-able friend std::ostream& operator << (std::ostream& os, const tuple& t) { return os << '(' << t.first << ',' << t.second << ',' << t.third << ',' << t.fourth << ',' << t.fifth << ',' << t.sixth << ')'; } //! Return minimum value of tuple using numeric_limits static tuple min_value() { return tuple(std::numeric_limits::min(), std::numeric_limits::min(), std::numeric_limits::min(), std::numeric_limits::min(), std::numeric_limits::min(), std::numeric_limits::min()); } //! Return maximum value of tuple using numeric_limits static tuple max_value() { return tuple(std::numeric_limits::max(), std::numeric_limits::max(), std::numeric_limits::max(), std::numeric_limits::max(), std::numeric_limits::max(), std::numeric_limits::max()); } }; //! Partial specialization for 1- \c tuple template struct tuple { //! First tuple component type typedef T1 first_type; //! First tuple component first_type first; template struct item_type { typedef typename IF::result result; }; //! Empty constructor tuple() { } //! Initializing constructor tuple(first_type first_) : first(first_) { } //! Equality comparison bool operator == (const tuple& t) const { return first == t.first; } //! Inequality comparison bool operator != (const tuple& t) const { return !(first == t.first); } //! Make tuple ostream-able friend std::ostream& operator << (std::ostream& os, const tuple& t) { return os << '(' << t.first << ')'; } //! Return minimum value of tuple using numeric_limits static tuple min_value() { return tuple(std::numeric_limits::min()); } //! Return maximum value of tuple using numeric_limits static tuple max_value() { return tuple(std::numeric_limits::max()); } }; //! Partial specialization for 2- \c tuple (equivalent to std::pair) template struct tuple { //! First tuple component type typedef T1 first_type; //! Second tuple component type typedef T2 second_type; template struct item_type { typedef typename SWITCH > > >::result result; }; //! First tuple component first_type first; //! Second tuple component second_type second; //! Empty constructor tuple() { } //! Initializing constructor tuple(first_type first_, second_type second_) : first(first_), second(second_) { } //! Equality comparison bool operator == (const tuple& t) const { return first == t.first && second == t.second; } //! Inequality comparison bool operator != (const tuple& t) const { return !(first == t.first && second == t.second); } //! Make tuple ostream-able friend std::ostream& operator << (std::ostream& os, const tuple& t) { return os << '(' << t.first << ',' << t.second << ')'; } //! Return minimum value of tuple using numeric_limits static tuple min_value() { return tuple(std::numeric_limits::min(), std::numeric_limits::min()); } //! Return maximum value of tuple using numeric_limits static tuple max_value() { return tuple(std::numeric_limits::max(), std::numeric_limits::max()); } }; //! Partial specialization for 3- \c tuple (triple) template struct tuple { //! First tuple component type typedef T1 first_type; //! Second tuple component type typedef T2 second_type; //! Third tuple component type typedef T3 third_type; template struct item_type { typedef typename SWITCH > > > >::result result; }; //! First tuple component first_type first; //! Second tuple component second_type second; //! Third tuple component third_type third; //! Empty constructor tuple() { } //! Construct tuple from components tuple(first_type _first, second_type _second, third_type _third) : first(_first), second(_second), third(_third) { } //! Equality comparison bool operator == (const tuple& t) const { return first == t.first && second == t.second && third == t.third; } //! Inequality comparison bool operator != (const tuple& t) const { return !(first == t.first && second == t.second && third == t.third); } //! Make tuple ostream-able friend std::ostream& operator << (std::ostream& os, const tuple& t) { return os << '(' << t.first << ',' << t.second << ',' << t.third << ')'; } //! Return minimum value of tuple using numeric_limits static tuple min_value() { return tuple(std::numeric_limits::min(), std::numeric_limits::min(), std::numeric_limits::min()); } //! Return maximum value of tuple using numeric_limits static tuple max_value() { return tuple(std::numeric_limits::max(), std::numeric_limits::max(), std::numeric_limits::max()); } }; //! Partial specialization for 4- \c tuple template struct tuple { //! First tuple component type typedef T1 first_type; //! Second tuple component type typedef T2 second_type; //! Third tuple component type typedef T3 third_type; //! Fourth tuple component type typedef T4 fourth_type; template struct item_type { typedef typename SWITCH > > > > >::result result; }; //! First tuple component first_type first; //! Second tuple component second_type second; //! Third tuple component third_type third; //! Fourth tuple component fourth_type fourth; //! Empty constructor tuple() { } //! Construct tuple from components tuple(first_type _first, second_type _second, third_type _third, fourth_type _fourth) : first(_first), second(_second), third(_third), fourth(_fourth) { } //! Equality comparison bool operator == (const tuple& t) const { return first == t.first && second == t.second && third == t.third && fourth == t.fourth; } //! Inequality comparison bool operator != (const tuple& t) const { return !(first == t.first && second == t.second && third == t.third && fourth == t.fourth); } //! Make tuple ostream-able friend std::ostream& operator << (std::ostream& os, const tuple& t) { return os << '(' << t.first << ',' << t.second << ',' << t.third << ',' << t.fourth << ')'; } //! Return minimum value of tuple using numeric_limits static tuple min_value() { return tuple(std::numeric_limits::min(), std::numeric_limits::min(), std::numeric_limits::min(), std::numeric_limits::min()); } //! Return maximum value of tuple using numeric_limits static tuple max_value() { return tuple(std::numeric_limits::max(), std::numeric_limits::max(), std::numeric_limits::max(), std::numeric_limits::max()); } }; //! Partial specialization for 5- \c tuple template struct tuple { //! First tuple component type typedef T1 first_type; //! Second tuple component type typedef T2 second_type; //! Third tuple component type typedef T3 third_type; //! Fourth tuple component type typedef T4 fourth_type; //! Fifth tuple component type typedef T5 fifth_type; template struct item_type { typedef typename SWITCH > > > > > >::result result; }; //! First tuple component first_type first; //! Second tuple component second_type second; //! Third tuple component third_type third; //! Fourth tuple component fourth_type fourth; //! Fifth tuple component fifth_type fifth; //! Empty constructor tuple() { } //! Construct tuple from components tuple(first_type _first, second_type _second, third_type _third, fourth_type _fourth, fifth_type _fifth) : first(_first), second(_second), third(_third), fourth(_fourth), fifth(_fifth) { } //! Equality comparison bool operator == (const tuple& t) const { return first == t.first && second == t.second && third == t.third && fourth == t.fourth && fifth == t.fifth; } //! Inequality comparison bool operator != (const tuple& t) const { return !(first == t.first && second == t.second && third == t.third && fourth == t.fourth && fifth == t.fifth); } //! Make tuple ostream-able friend std::ostream& operator << (std::ostream& os, const tuple& t) { return os << '(' << t.first << ',' << t.second << ',' << t.third << ',' << t.fourth << ',' << t.fifth << ')'; } //! Return minimum value of tuple using numeric_limits static tuple min_value() { return tuple(std::numeric_limits::min(), std::numeric_limits::min(), std::numeric_limits::min(), std::numeric_limits::min(), std::numeric_limits::min()); } //! Return maximum value of tuple using numeric_limits static tuple max_value() { return tuple(std::numeric_limits::max(), std::numeric_limits::max(), std::numeric_limits::max(), std::numeric_limits::max(), std::numeric_limits::max()); } }; /* template typename tuple_type::item_type::result get(const tuple_type & t) { return NULL; } */ template struct tuple_less1st { typedef TupleType value_type; bool operator () (const value_type& a, const value_type& b) const { return (a.first < b.first); } static value_type min_value() { return value_type::min_value(); } static value_type max_value() { return value_type::max_value(); } }; template struct tuple_greater1st { typedef TupleType value_type; bool operator () (const value_type& a, const value_type& b) const { return (a.first > b.first); } static value_type min_value() { return value_type::max_value(); } static value_type max_value() { return value_type::min_value(); } }; template struct tuple_less1st_less2nd { typedef TupleType value_type; bool operator () (const value_type& a, const value_type& b) const { if (a.first == b.first) return (a.second < b.second); return (a.first < b.first); } static value_type min_value() { return value_type::min_value(); } static value_type max_value() { return value_type::max_value(); } }; template struct tuple_less2nd { typedef TupleType value_type; bool operator () (const value_type& a, const value_type& b) const { return (a.second < b.second); } static value_type min_value() { return value_type::min_value(); } static value_type max_value() { return value_type::max_value(); } }; namespace stream { /** * Counter for creating tuple indexes for example. */ template struct counter { public: typedef ValueType value_type; protected: value_type m_count; public: counter(const value_type& start = 0) : m_count(start) { } const value_type& operator * () const { return m_count; } counter& operator ++ () { ++m_count; return *this; } bool empty() const { return false; } }; /** * Concatenates two tuple streams as streamA . streamB */ template class concatenate { public: typedef typename StreamA::value_type value_type; private: StreamA& A; StreamB& B; public: concatenate(StreamA& A_, StreamB& B_) : A(A_), B(B_) { assert(!A.empty()); assert(!B.empty()); } const value_type& operator * () const { assert(!empty()); if (!A.empty()) { return *A; } else { return *B; } } concatenate& operator ++ () { assert(!empty()); if (!A.empty()) { ++A; } else if (!B.empty()) { ++B; } return *this; } bool empty() const { return (A.empty() && B.empty()); } }; } // namespace stream STXXL_END_NAMESPACE #endif // !STXXL_COMMON_TUPLE_HEADER