ENTITY_LIST Class Arguments
List of: Discussion Topic
Subjects: Extending ACIS, C++ Interface
Contents: Application Development Manual

When a group of similar arguments must be returned and the number of arguments is not known in advance, they are returned as a list of entities using class ENTITY_LIST. For instance, when the routine api_cover_sheet is used to find every simple loop of external edges of a sheet body, the faces made are put into an ENTITY_LIST, which is returned.

The ENTITY_LIST implementation uses hashing, so look up is fast if the lists are not long. It is also efficient for repeated lookups of the same ENTITY.

ENTITY_LIST provides constructor (which creates an empty list) and destructor functions to add an entity to the list, look up an entity by pointer value, to remove an entity from the list, and to count the number of entities in the list. It also provides an overloaded [ ] operator for access by position, and two methods, init and next, for faster sequencing through the array.

The preferred way of accessing the items in the list is through ENTITY_LIST::init, which rewinds the list, and ENTITY_LIST::next, which returns the next undeleted item, as is shown in Example 8-6.

C++ Example

ENTITY_LIST my_face_list;
api_cover_sheet(sheet_body, new_surface, my_face_list);
ENTITY* my_list_item
my_face_list.init();
while ((my_list_item=my_face_list.next()) != NULL){

if is_FACE(my_list_item){

.

.

.

}
}

Example 8-6. ENTITY_LIST Using init and next

The ENTITY_LIST class is a variable length associative array of ENTITY pointers. When using the subscript operator, a cast is required to coerce the ENTITY pointer into a pointer of the correct type. Refer to Example 8-7. For best performance in loops that step through this list by index value, have the loops increment rather than decrement the index counter. Internal operations for methods like operator[] and remove store the index counter from the previous operation, allowing faster access to the next indexed item when indexing up.

C++ Example

ENTITY_LIST my_face_list;
api_cover_sheet(sheet_body, new_surface, my_face_list);
int number_of_faces = my_face_list.count();
for (int i = 0; i < number_of_faces; i++){

FACE* face = (FACE*)my_face_list[i];

.

.

.
}

Example 8-7. ENTITY_LIST using Cast and the Operator []
PDF/APPDEV/08EXT.PDF
HTM/DATA/ACIS/APPDEV/08EXT/0016.HTM