34#ifndef _CHOMP_STRUCT_WORDS_H_
35#define _CHOMP_STRUCT_WORDS_H_
86 const char *
text ()
const;
89 operator const char * ()
const;
99 operator int ()
const;
121 len = s ? strlen (s) : 0;
128 throw "Not enough memory to create a word.";
143 throw "Not enough memory to copy a word.";
165 throw "Not enough memory to copy a word.";
183inline word::operator
const char * ()
const
197 int newlen =
len + w.
len;
198 char *newtxt =
new char [newlen + 1];
199 strcpy (newtxt,
txt);
200 strcat (newtxt, w.
txt);
214inline word::operator int ()
const
222 std::istringstream str (s);
234 int len = w. length ();
237 const char *txt = w. text ();
238 int_t code = (
static_cast<int_t> (txt [0]) << 7) ^
239 (
static_cast<int_t> (txt [len - 1]));
241 code ^=
static_cast<int_t> (txt [2]) << 15;
247 int len = w. length ();
250 const char *txt = w. text ();
252 (
static_cast<int_t> (txt [len - 1] << 17));
254 code ^=
static_cast<int_t> (txt [3]) << 8;
261 if (w1. length () != w2. length ())
265 return !strcmp ((
const char *) w1, (
const char *) w2);
279 return !strcmp ((
const char *) w, c);
306 const char *c1 = (
const char *) w1;
307 const char *c2 = (
const char *) w2;
309 while (*c1 && *c2 && ((*c1) == (*c2)))
314 return ((*c1) < (*c2));
346 std::ostringstream s;
348 w += s. str (). c_str ();
359 out << (
const char *) w;
368 int ch = in. peek ();
369 while ((ch !=
' ') && (ch !=
'\r') && (ch !=
'\n') && (ch !=
'\t') &&
372 buf [pos ++] = in. get ();
This is a template for a set of objects of the given type.
A word, that is, a string with very few properties.
const char * text() const
Returns a pointer to the contents of the word.
word()
Default constructor of an empty word.
char * txt
A memory buffer containing the word.
word & operator=(const word &w)
Assignment operator.
int len
The length of the word (without the terminating zero character).
word operator+(const word &w) const
Word concatenation operator.
int length() const
Returns the length of the word (without the ending zero char).
word & operator+=(const word &w)
Word concatenation operator.
This file contains some precompiler definitions which indicate the operating system and/or compiler u...
int int_t
Index type for indexing arrays, counting cubes, etc.
This file contains the definition of the container "hashedset" which can be used to represent a set o...
This file defines a class "integer" which represents the ring of integers or the field of integers mo...
hashedset< word > words
The default type of a set of words.
int operator<=(const word &w1, const word &w2)
Compares two words in an alphabetical way (by ASCII codes).
std::ostream & operator<<(std::ostream &out, const bincube< Dim, twoPower > &b)
int_t hashkey2(const hashNumber< Number > &n)
The second hashing key.
int operator>=(const word &w1, const word &w2)
Compares two words in an alphabetical way (by ASCII codes).
bool operator<(const integer &x, const integer &y)
bool operator!=(const typename bincube< Dim, twoPower >::neighborhood_iterator &x1, const typename bincube< Dim, twoPower >::neighborhood_iterator &x2)
std::istream & operator>>(std::istream &in, bincube< Dim, twoPower > &b)
int_t hashkey1(const hashNumber< Number > &n)
The first hashing key.
bool operator==(const typename bincube< Dim, twoPower >::neighborhood_iterator &x1, const typename bincube< Dim, twoPower >::neighborhood_iterator &x2)
bool operator>(const integer &x, const integer &y)
This namespace contains the entire CHomP library interface.
This file contains some useful functions related to the text input/output procedures.