Phillips et al.: "Semiotic Modelling for Text String De-Duplication"


The first String constructor function (lines 20 through 24) takes as its argument a pointer to character data, assigns memory for a new string of appropriate length, and copies the characters to the new string. The second String constructor function (lines 26 through 30) is similar to the first, but simply makes a copy of an existing object.

The set function (lines 32 through 39) changes the contents of existing character data by substituting into the data memory the string pointed to by the function argument.

An overloaded equality operator (lines 41 through 43) takes a string by reference and copies another string to the string passed as an argument.

The *get function (lines 45 through 47) simply returns a pointer to data.

Lines 49 through 51 is an equality function that compares two strings, returns a "true" (or nonzero) value if the strings are the same, or returns "false" (or zero) if the strings are different.

A logical equality operator (defined in Lines 53 through 55), denoted as == (two consecutive equals signs), can be used in Boolean expressions, and builds on the equality function in lines 49 through 51.

A concatenate operator is defined in lines 57 through 65. It is denoted as +=, and it takes an existing string of character data, and appends additional character string data onto the end of the original string. It uses the library functions strcat and strcpy in the implementation of the class member operator.

A print function (lines 67 through 70) displays the contents of the data, and (with the optional line shown as line 69) can be used to give the string length of the data being displayed. As mentioned previously (vide supra), the stack approach to character data does not include spacing between words as characters in the stack. This is verified when running the program with line 69 included, as opposed to the version listed in the Appendix, where it has been Rem-ed out (or, in C++ vernacular, "//-ed out"). With line 69 included, the string length of any word is calculated using the library strlen function, and printed out alongside each word. Thus, it is easy to verify that the spaces are not included among the stack data.

The final class member function is the destructor function. When there is no further need for data to be stored, the memory can be deallocated, thereby adding computational efficiency.

Page - 1     Page + 1

AS/SA Nº 6/7, Article 1 : Page 9 / 11

© 1999, AS/SA

E-mail to the editors
Pour écrire à la rédaction