[SESI logo]

Houdini Development Toolkit - Version 6.5

Side Effects Software Inc. 2004

Utility Classes


UT_StringArray Class

This is a class that implements a resizable array of strings. Each string is stored and can be accessed as a UT_String. All strings stored in this class are copied from the source strings. This is slightly less efficient, but eliminates a great deal of memory management code.


Methods

constructors

The default constructor does not allocate any memory for the array.

A constructor taking a const char ** is provided to create the array filled from a static list of strings. The provided array must be terminated with a null pointer.

A copy constructor is also provided.

int append(const char *str)

Appends the provided string to the current entries and returns its index in the array.

int insert(const char *str, int idx)

Inserts the given string at the specified position, shifting the rest of the elements to make space for the new element. Returns the given index.

int remove(int idx)

Removes the string at the specified position in the array. The returned value is the provided index.

void removeLast()

Removes the last string in the array.

void clear()

Removes all strings from the array.

int entries()

Return the number of elements in the array.

void resize(int nsize)

Sets the amount of space available for strings in the array. If this number is less than the current number of strings, any strings past the new end of the array are deleted. If this number is greater than or equal to the current number of string, no new strings are actually allocated, and the value returned by the entries() function will not be affected. This function just reserves space for new strings. This can increase efficiency if you know in advance that a large number of strings are going to be added to the array.

const UT_StringArray &operator=(const UT_StringArray &src)

The copy operator copies each string from the source array into the destination array.

UT_String &operator()(int idx) const UT_String &operator()(int idx) const

These functions return non-const and const references respectively to the string at the specified location in the array.

UT_String &last() const UT_String &last() const

These functions return non-const and const references respectively to the last string in the array.

bool operator==(const UT_StringArray &src) const

Returns true if the arrays have the same number of strings, and each string matches the corresponding string in the other arrary.

int find(const char *str)

Search for the given string. Returns the index of the found string in the array, or -1 if the string is not found.

void sort(bool forward = true, bool numbered = true)

Sorts the array into alphabetical order. The forward parameter specifies whether the array should be in forward or reverse alphabetical order. The numbered parameter specifies whether strings with numbers should be sorted according to the numeric values found in the strings, or whether strict alphabetical ordering should be used. For example, foo1.pic would appear after foo10.pic if numbered is set to false, or before it if numbered is set to true.

int sortedInsert(const char *str, bool forward = true, bool numbered = true)

Inserts the specified string in its proper location according to the ordering parameters forward and numbered. See the sort function for a description of these parameters. The array must be currently sorted for this function to work. The returned value is the location where the new string was inserted.

int sortedFind(const char *str, bool forward = true, bool numbered = true)

Finds the specified string inthe array using a binary search technique, using the ordering parameters forward and numbered. See the sort function for a description of these parameters. The array must be currently sorted for this function to work. The returned value is the location where the new string was inserted.


Table of Contents
Operators | Surface Operations | Particle Operations | Composite Operators | Channel Operators
Material & Texture | Objects | Command and Expression | Render Output |
Mantra Shaders | Utility Classes | Geometry Library | Image Library | Clip Library
Customizing UI | Questions & Answers

Copyright © 2004 Side Effects Software Inc.
477 Richmond Street West, Toronto, Ontario, Canada M5V 3E7