sequence< contents > Class Template Reference

An array that can be alphabetically ordered against other instances. More...

#include <sequence.h>

Inheritance diagram for sequence< contents >:

Inheritance graph
[legend]
Collaboration diagram for sequence< contents >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 sequence (int number=0, const contents *initial=NIL, u_short flags=array< contents >::EXPONENTIAL_GROWTH|array< contents >::FLUSH_INVISIBLE)
 Constructs a sequence with room for "number".
 sequence (const array< contents > &to_copy)
 Constructs a sequence from an array.
bool operator< (const sequence &s2) const
 Returns true if "this" is lexicographically less than "s2".
bool operator<= (const sequence &s2) const
 Returns true if "this" is lexicographically less than or equal to "s2".
bool operator== (const sequence &s2) const
 Returns true if "this" is lexicographically equal to "s2".
bool operator!= (const sequence &s2) const
 Returns true if "this" is lexicographically not equal to "s2".
bool operator> (const sequence &s2) const
 Returns true if "this" is lexicographically greater than "s2".
bool operator>= (const sequence &s2) const
 Returns true if "this" is greater than or equal to "s2".
int find (const contents &to_find, int &position, outcome &outcome) const
 Locates "to_find" if possible and returns its index in "this".
int find (const sequence &to_find, int &position, outcome &outcome) const
 A synonym for find() which operates on a sequence instead.

Detailed Description

template<class contents>
class sequence< contents >

An array that can be alphabetically ordered against other instances.

The sequence is an object that represents an array of objects where there is a lexicographical ordering that can completely order sequences against other sequences of the same type. This is used as a base object for sortable classes, like the istring.

Definition at line 29 of file sequence.h.


Constructor & Destructor Documentation

template<class contents>
sequence< contents >::sequence ( int  number = 0,
const contents *  initial = NIL,
u_short  flags = array<contents>::EXPONENTIAL_GROWTH | array<contents>::FLUSH_INVISIBLE 
) [inline]

Constructs a sequence with room for "number".

The initial contents are copied from "initial_contents" unless NIL is passed in instead. If "initial_contents" is not NIL, then it must point to an array of "contents" that contains at least "number" of them.

Definition at line 32 of file sequence.h.

template<class contents>
sequence< contents >::sequence ( const array< contents > &  to_copy  )  [inline]

Constructs a sequence from an array.

Definition at line 40 of file sequence.h.


Member Function Documentation

template<class contents>
bool sequence< contents >::operator< ( const sequence< contents > &  s2  )  const [inline]

Returns true if "this" is lexicographically less than "s2".

The comparison functions are based on a canonical ordering of arrays: sequences of zero length are equal. Otherwise, sequences of the same length are judged by their elements (first, second, ...) in order until the elements differ; an element that is greater than another makes its object "greater than" the other object. Only if the sequences are of equal length and each element is equal does sequence equality hold. If the sequences are of unequal lengths, then the comparison above occurs until one of the sequences runs out of contents. if they are equal to that point, then the longer one is considered greater than the shorter.

Definition at line 43 of file sequence.h.

template<class contents>
bool sequence< contents >::operator<= ( const sequence< contents > &  s2  )  const [inline]

Returns true if "this" is lexicographically less than or equal to "s2".

Definition at line 54 of file sequence.h.

template<class contents>
bool sequence< contents >::operator== ( const sequence< contents > &  s2  )  const [inline]

Returns true if "this" is lexicographically equal to "s2".

Definition at line 57 of file sequence.h.

template<class contents>
bool sequence< contents >::operator!= ( const sequence< contents > &  s2  )  const [inline]

Returns true if "this" is lexicographically not equal to "s2".

Definition at line 60 of file sequence.h.

template<class contents>
bool sequence< contents >::operator> ( const sequence< contents > &  s2  )  const [inline]

Returns true if "this" is lexicographically greater than "s2".

Definition at line 63 of file sequence.h.

template<class contents>
bool sequence< contents >::operator>= ( const sequence< contents > &  s2  )  const [inline]

Returns true if "this" is greater than or equal to "s2".

Definition at line 66 of file sequence.h.

template<class contents>
int sequence< contents >::find ( const contents &  to_find,
int &  position,
outcome outcome 
) const

Locates "to_find" if possible and returns its index in "this".

The find starts looking at "position". If the outcome is SUCCESS, then its index is returned. if the outcome is NOT_FOUND, then "to_find" is not located in the sequence. OUT_OF_RANGE is the outcome if "position" is invalid. "position" is updated for a successful find.

Definition at line 37 of file sequence.cpp.

References bounds_return, array< contents >::length(), common::NOT_FOUND, common::OKAY, common::OUT_OF_RANGE, and this.

template<class contents>
int sequence< contents >::find ( const sequence< contents > &  to_find,
int &  position,
outcome outcome 
) const

A synonym for find() which operates on a sequence instead.

Definition at line 53 of file sequence.cpp.

References bounds_return, array< contents >::last(), array< contents >::length(), common::NOT_FOUND, common::OKAY, common::OUT_OF_RANGE, and this.


The documentation for this class was generated from the following files:
Generated on Wed Jul 23 04:35:28 2008 for HOOPLE Libraries by  doxygen 1.5.1