quick start:g++ [flags ...] file ... #include <Pair.h> Pair(const Pair& arg); boolean assign(const Pair<T1, T2>& arg); T1& first(); T1& second(); boolean clear(Integral::CMODE cmode);
description:// declare a pair and insert a character and string in it // Pair<Char,String> pair0; Char char(L'a'); String str(L"aye"); pair0.assign(char,str); // use the copy constructor to create a second pair // Pair<Char,String> pair1(pair0); // test the characters for equality // if (!pair1.first().eq(pair2.first())) { Console::put(L"error"); }
static const SysString CLASS_NAME = L"Pair";
static const SysString DEF_PARAM = L"item";
static const SysString BLOCK_START_STR = L"{";
static const SysString BLOCK_DELIM_STR = L"}, {";
static const SysString BLOCK_END_STR = L"}";
static const SysString BLOCK_TERM_STR = L";\n";
static const long ERR = 41800;
T1 obj1_d;
T2 obj2_d;
static MemoryManager mgr_d;
static const String& name();
static boolean diagnose(Integral::DEBUG debug_level);
boolean debug(const unichar* message) const;
static boolean setDebug(Integral::DEBUG debug_level);
~Pair();
Pair();
Pair(const Pair<T1, T2>& arg);
boolean assign(const Pair<T1, T2>& arg);
Pair<T1, T2>& operator=(const Pair<T1, T2>& arg);
boolean eq(const Pair<T1, T2>& arg) const;
long sofSize() const;
boolean read(Sof& sof, long tag);
boolean write(Sof& sof, long tag) const;
boolean read(Sof& sof, long tag, const String& name);
boolean write(Sof& sof, long tag, const String& name) const;
boolean readData(Sof& sof, const String& pname = DEF_PARAM,long size = SofParser::FULL_OBJECT, boolean param_a = true, boolean nested_a = false);
boolean writeData(Sof& sof, const String& pname = DEF_PARAM) const;
static void* operator new(size_t size);
static void* operator new[](size_t size);
static void operator delete(void* ptr);
static void operator delete[](void* ptr);
static boolean setGrowSize(long grow_size);
boolean clear(Integral::CMODE cmode = Integral::DEF_CMODE);
Pair(const T1& obj1, const T2& obj2);
boolean assign(const T1& obj1, const T2& obj2);
T1& first();
const T1& first() const;
T2& second();
const T2& second() const;
#include <Char.h> #include <Vector.h> #include <Pair.h> int main () { // we want to keep up with characters and associated strings. we // could do this with parallel vectors, but combining the inner // data is more natural. // Vector< Pair<Char, String> > letters(5); letters(0).first().assign(L'a'); letters(1).first().assign(L'b'); letters(2).first().assign(L'c'); letters(3).first().assign(L'd'); letters(4).first().assign(L'e'); letters(0).second().assign(L"aye"); letters(1).second().assign(L"be"); letters(2).second().assign(L"see"); letters(3).second().assign(L"de"); letters(4).second().assign(L"e"); // we might also want to weight these // Vector <Pair < Long, Pair <Char, String> > > wlet(5); for (long i = 0; i < 5; i++) { wlet(i).first().assign(i * 3); wlet(i).second().assign(letters(i)); } wlet.debug(L"wlet"); // so far all this can easily be done with parallel arrays, but // if we so desired we could also make a graph out of these. // exit gracefully // Integral::exit(); }