summaryrefslogtreecommitdiff
path: root/src/util/ntuple.h
diff options
context:
space:
mode:
authorMorgan Deters <mdeters@gmail.com>2011-05-23 21:58:12 +0000
committerMorgan Deters <mdeters@gmail.com>2011-05-23 21:58:12 +0000
commit3f7f9df5f0c419b7f7dd39e32852161f406a441f (patch)
tree67ae6454e4496f6370cf8236500946e2c7e926b0 /src/util/ntuple.h
parent91656937b2188f05cdd9b42955c04e6157349285 (diff)
Merge from arrays2 branch.
Diffstat (limited to 'src/util/ntuple.h')
-rw-r--r--src/util/ntuple.h93
1 files changed, 93 insertions, 0 deletions
diff --git a/src/util/ntuple.h b/src/util/ntuple.h
new file mode 100644
index 000000000..a3b0dfdf4
--- /dev/null
+++ b/src/util/ntuple.h
@@ -0,0 +1,93 @@
+/********************* */
+/*! \file ntuple.h
+ ** \verbatim
+ ** Original author: mdeters
+ ** Major contributors: lianah
+ ** Minor contributors (to current version): none
+ ** This file is part of the CVC4 prototype.
+ ** Copyright (c) 2009, 2010, 2011 The Analysis of Computer Systems Group (ACSys)
+ ** Courant Institute of Mathematical Sciences
+ ** New York University
+ ** See the file COPYING in the top-level source directory for licensing
+ ** information.\endverbatim
+ **
+ ** \brief Similar to std::pair<>, for triples and quadruples
+ **
+ ** Similar to std::pair<>, for triples and quadruples. Once we move to c++0x, this
+ ** can be removed in favor of (standard-provided) N-ary tuples.
+ **/
+
+#include "cvc4_private.h"
+
+#ifndef __CVC4__NTUPLE_H
+#define __CVC4__NTUPLE_H
+
+namespace CVC4 {
+
+template <class T1, class T2, class T3>
+class triple {
+public:
+ T1 first;
+ T2 second;
+ T3 third;
+};/* class triple<> */
+
+template <class T1, class T2, class T3>
+inline triple<T1, T2, T3>
+make_triple(const T1& t1, const T2& t2, const T3& t3) {
+ return triple<T1, T2, T3>(t1, t2, t3);
+}/* make_triple() */
+
+template <class T1, class T2, class T3, class T4>
+class quad {
+public:
+ T1 first;
+ T2 second;
+ T3 third;
+ T4 fourth;
+ quad(const T1& t1, const T2& t2, const T3& t3, const T4& t4) {
+ first = t1;
+ second = t2;
+ third = t3;
+ fourth = t4;
+ }
+};/* class quad<> */
+
+template <class T1, class T2, class T3, class T4>
+bool operator==(const quad<T1,T2,T3,T4>& x,
+ const quad<T1,T2,T3,T4>& y) {
+ return (x.first==y.first && x.second==y.second &&
+ x.third == y.third && x.fourth==y.fourth);
+}
+
+template <class T1, class T2, class T3, class T4>
+bool operator<(const quad<T1,T2,T3,T4>& x,
+ const quad<T1,T2,T3,T4>& y) {
+ if(x.first< y.first) {
+ return true;
+ }
+ else if (x.first == y.first) {
+ if(x.second < y.second) {
+ return true;
+ }
+ else if(y.second == y.second) {
+ if(x.third < y.third) {
+ return true;
+ }
+ else if (x.fourth < y.fourth) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+template <class T1, class T2, class T3, class T4>
+inline quad<T1, T2, T3, T4>
+make_quad(const T1& t1, const T2& t2, const T3& t3, const T4& t4) {
+ return quad<T1, T2, T3, T4>(t1, t2, t3, t4);
+}/* make_quad() */
+
+}/* CVC4 namespace */
+
+#endif /* __CVC4__NTUPLE_H */
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback