X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2Fstlplus%2Fcontainers%2Ftriple.tpp;h=50c2d7072b7864cb38c71e38d03866d577d773b3;hp=3c1fa30d40e365863de9009bb5df794dabf9d055;hb=4f6e4488a55f7e3ba3f7485d78177f793c0eab9a;hpb=574af38ed616d1adfa5e6ce35f67cda1f707f89d diff --git a/src/stlplus/containers/triple.tpp b/src/stlplus/containers/triple.tpp index 3c1fa30..50c2d70 100644 --- a/src/stlplus/containers/triple.tpp +++ b/src/stlplus/containers/triple.tpp @@ -1,56 +1,67 @@ -//////////////////////////////////////////////////////////////////////////////// - -// Author: Andy Rushton, from an original by Dan Milton -// Copyright: (c) Southampton University 1999-2004 -// (c) Andy Rushton 2004-2009 -// License: BSD License, see ../docs/license.html - -//////////////////////////////////////////////////////////////////////////////// - -namespace stlplus -{ - - //////////////////////////////////////////////////////////////////////////////// - // the triple class - - template - triple::triple(void) : - first(), second(), third() - { - } - - template - triple::triple(const T1& p1, const T2& p2, const T3& p3) : - first(p1), second(p2), third(p3) - { - } - - template - triple::triple(const triple& t2) : - first(t2.first), second(t2.second), third(t2.third) - { - } - - //////////////////////////////////////////////////////////////////////////////// - // creation - - template - triple make_triple(const T1& first, const T2& second, const T3& third) - { - return triple(first,second,third); - } - - //////////////////////////////////////////////////////////////////////////////// - // comparison - - template - bool operator == (const triple& left, const triple& right) - { - // triples are equal if all elements are equal - return left.first == right.first && left.second == right.second && left.third == right.third; - } - - //////////////////////////////////////////////////////////////////////////////// - -} // end namespace stlplus - +//////////////////////////////////////////////////////////////////////////////// + +// Author: Andy Rushton, from an original by Dan Milton +// Copyright: (c) Southampton University 1999-2004 +// (c) Andy Rushton 2004 onwards +// License: BSD License, see ../docs/license.html + +//////////////////////////////////////////////////////////////////////////////// + +namespace stlplus +{ + + //////////////////////////////////////////////////////////////////////////////// + // the triple class + + template + triple::triple(void) : + first(), second(), third() + { + } + + template + triple::triple(const T1& p1, const T2& p2, const T3& p3) : + first(p1), second(p2), third(p3) + { + } + + template + triple::triple(const triple& t2) : + first(t2.first), second(t2.second), third(t2.third) + { + } + + //////////////////////////////////////////////////////////////////////////////// + // creation + + template + triple make_triple(const T1& first, const T2& second, const T3& third) + { + return triple(first,second,third); + } + + //////////////////////////////////////////////////////////////////////////////// + // comparison + + template + bool operator == (const triple& left, const triple& right) + { + // triples are equal if all elements are equal + return left.first == right.first && left.second == right.second && left.third == right.third; + } + + template + bool operator < (const triple& left, const triple& right) + { + // use the < operator on each element + return left.first < right.first ? true : + right.first < left.first ? false : + left.second < right.second ? true : + right.second < left.second ? false : + left.third < right.third; + } + + //////////////////////////////////////////////////////////////////////////////// + +} // end namespace stlplus +