00001 #ifndef SEQUENCE_CLASS
00002 #define SEQUENCE_CLASS
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "array.h"
00019
00021
00028 template <class contents>
00029 class sequence : public array<contents>
00030 {
00031 public:
00032 inline sequence(int number = 0, const contents *initial = NIL,
00033 u_short flags = array<contents>::EXPONENTIAL_GROWTH
00034 | array<contents>::FLUSH_INVISIBLE)
00035 : array<contents>(number, initial, flags) {}
00037
00041 inline sequence(const array<contents> &to_copy) : array<contents>(to_copy) {}
00043
00044 inline bool operator < (const sequence &s2) const
00045 { return comparator(s2) < 0; }
00047
00056 inline bool operator <= (const sequence &s2) const
00057 { return comparator(s2) <= 0; }
00059 inline bool operator == (const sequence &s2) const
00060 { return comparator(s2) == 0; }
00062 inline bool operator != (const sequence &s2) const
00063 { return comparator(s2) != 0; }
00065 inline bool operator > (const sequence &s2) const
00066 { return comparator(s2) > 0; }
00068 inline bool operator >= (const sequence &s2) const
00069 { return comparator(s2) >= 0; }
00071
00072 int find(const contents &to_find, int &position, outcome &outcome) const;
00074
00078 int find(const sequence &to_find, int &position, outcome &outcome) const;
00080
00081 private:
00082 int comparator(const sequence &s2) const;
00084
00087 };
00088
00090
00092 class byte_sequence : public sequence<byte>
00093 {
00094 public:
00095 byte_sequence(int number = 0, const byte *initial_contents = NIL)
00096 : sequence<byte>(number, initial_contents, SIMPLE_COPY | EXPONE) {}
00097 byte_sequence(const byte_sequence &to_copy) : sequence<byte>(to_copy) {}
00098 byte_sequence(const sequence<byte> &to_copy) : sequence<byte>(to_copy) {}
00099 };
00100
00102 class flexichar_sequence : public sequence<flexichar>
00103 {
00104 public:
00105 flexichar_sequence(int number = 0, const flexichar *initial_contents = NIL)
00106 : sequence<flexichar>(number, initial_contents,
00107 SIMPLE_COPY | EXPONE) {}
00108 flexichar_sequence(const flexichar_sequence &to_copy)
00109 : sequence<flexichar>(to_copy) {}
00110 flexichar_sequence(const sequence<flexichar> &to_copy)
00111 : sequence<flexichar>(to_copy) {}
00112 };
00113
00114 #endif
00115