tsc_EntityList

This class is a list of entities, each entity being defined by the tsc_Entity class.  A tsc_Entity can be a Point, Line, or Arc.  Each of these types may be present in a tsc_EntityList, but in addition points may instead be in a tsc_PointList which provides a number of extra functions suitable only for points.

Lists of types other than points, or any mixture of types (including points), are placed in a tsc_EntityList.  A tsc_PointList may be constructed from a tsc_EntityList; when this occurs, the point list will copy only point objects from the original enity list, and all other types are skipped.

Any tsc_PointList or tsc_EntityList may contain objects from multiple different job or csv files at the same time.

Constructors

Typically, entity lists are obtained from other objects (such as the job or data model) rather than being constructed from scratch.

Construct an empty list:

tsc_EntityList ();
The copy constructor makes a reference to the same list.  This means that any change to the copy will also occur in the original.

tsc_EntityList (const tsc_EntityList& copy);

Member functions

A shallow copy of the list makes a new list, though the entries in the list still point to the same objects.

tsc_EntityList Clone() const;
The nth object in the list is accessed with the [index] operator.  The sequence of the objects in the list depends on where the list came from.

tsc_Entity operator[] (int item) const;

int Count () const;
The number of objects in the list is returned.

bool IsEmpty() const;
Returns true if the list is empty.

void Append (const tsc_Entity& entity);
Appends an entity to the end of the list.

void Append (const tsc_EntityList& entityList);
Appends another entity list to the end of the list.

void Remove (const tsc_Entity& entity);
Removes an entity from the list.  Note that he list will be compacted. To remove many items, use one of the filtering methods below.

void Remove (int index);
Removes one item from the list.

void Clear ();
Removes all entities from the list.

tsc_Job&  Parent();
A reference to the parent object, being the job within which these objects exist.

Filtering the list

These functions remove all but the selected items from an existing list.  They are significantly faster than iterating through the list and accessing or removing the individual objects.  Also see tsc_IEntityFilter for details and an example of its use.

void RemoveDeleted ();
Remove all deleted items:

void SelectBy (tsc_IEntityFilter* entityTest);
Given an interface which implements a test function, remove all items from the list which fail the test.  A NULL filter will result in no filtering - all objects will be retained.

int Find (tsc_IEntityFilter* entityTest, int startIndex = 0);
Given an interface which implements a test function, return the index of the next item in the list, starting with the item at startIndex, which meets the test condition.   If no match is found, -1 is returned.