# SimSet

A collection of SimObjects.

## Callbacks

```
void
```

onObjectAdded(SimObject object)

Called when an object is added to the set.

```
void
```

onObjectRemoved(SimObject object)

Called when an object is removed from the set.

## Public Functions

```
bool
```

acceptsAsChild(SimObject obj)

Test whether the given object may be added to the set.

```
void
```

bringToFront(SimObject obj)

Make the given object the first object in the set.

```
void
```

callOnChildren(string method, string args...)

Call a method on all objects contained in the set.

```
void
```

callOnChildrenNoRecurse(string method, string args...)

Call a method on all objects contained in the set.

```
void
```

clear()

Remove all objects from the set.

```
void
```

Delete all objects in the set.

findObjectByInternalName(string internalName, bool searchChildren)

Find an object in the set by its internal name.

```
int
```

getCount()

Get the number of objects contained in the set.

```
int
```

Get the number of direct and indirect child objects contained in the set.

```
int
```

getObjectIndex(SimObject obj)

Return the index of the given object in this set.

```
void
```

Dump a list of all objects contained in the set to the console.

```
void
```

pushToBack(SimObject obj)

Make the given object the last object in the set.

```
void
```

reorderChild(SimObject child1, SimObject child2)

Make sure child1 is ordered right before child2 in the set.

```
void
```

sort(string callbackFunction)

Sort the objects in the set using the given comparison function.

## Detailed Description

A collection of SimObjects.

It is often necessary to keep track of an arbitrary set of SimObjects. For instance, Torque's networking code needs to not only keep track of the set of objects which need to be ghosted, but also the set of objects which must *always* be ghosted. It does this by working with two sets. The first of these is the RootGroup (which is actually a SimGroup) and the second is the GhostAlwaysSet, which contains objects which must always be ghosted to the client.

Some general notes on SimSets:

Membership is not exclusive. A SimObject may be a member of multiple SimSets.

A SimSet does not destroy subobjects when it is destroyed.

A SimSet may hold an arbitrary number of objects.

## Callbacks

onObjectAdded(SimObject object)

Called when an object is added to the set.

**Parameters:**

object | The object that was added. |

onObjectRemoved(SimObject object)

Called when an object is removed from the set.

**Parameters:**

object | The object that was removed. |

## Public Functions

acceptsAsChild(SimObject obj)

Test whether the given object may be added to the set.

**Parameters:**

obj | The object to test for potential membership. |

True if the object may be added to the set, false otherwise.

add(SimObject objects...)

Add the given objects to the set.

**Parameters:**

objects | The objects to add to the set. |

bringToFront(SimObject obj)

Make the given object the first object in the set.

**Parameters:**

obj | The object to bring to the frontmost position. Must be contained in the set. |

callOnChildren(string method, string args...)

Call a method on all objects contained in the set.

**Parameters:**

method | The name of the method to call. |

args | The arguments to the method. |

note:This method recurses into all SimSets that are children to the set.

callOnChildrenNoRecurse(string method, string args...)

Call a method on all objects contained in the set.

**Parameters:**

method | The name of the method to call. |

args | The arguments to the method. |

note:This method does not recurse into child SimSets.

clear()

Remove all objects from the set.

deleteAllObjects()

Delete all objects in the set.

findObjectByInternalName(string internalName, bool searchChildren)

Find an object in the set by its internal name.

**Parameters:**

internalName | The internal name of the object to look for. |

searchChildren | If true, SimSets contained in the set will be recursively searched for the object. |

The object with the given internal name or 0 if no match was found.

getCount()

Get the number of objects contained in the set.

The number of objects contained in the set.

getFullCount()

Get the number of direct and indirect child objects contained in the set.

The number of objects contained in the set as well as in other sets contained directly or indirectly in the set.

getObject(uint index)

Get the object at the given index.

**Parameters:**

index | The object index. |

The object at the given index or -1 if index is out of range.

getObjectIndex(SimObject obj)

Return the index of the given object in this set.

**Parameters:**

obj | The object for which to return the index. Must be contained in the set. |

The index of the object or -1 if the object is not contained in the set.

getRandom()

Return a random object from the set.

A randomly selected object from the set or -1 if the set is empty.

isMember(SimObject obj)

Test whether the given object belongs to the set.

**Parameters:**

obj | The object. |

True if the object is contained in the set; false otherwise.

listObjects()

Dump a list of all objects contained in the set to the console.

pushToBack(SimObject obj)

Make the given object the last object in the set.

**Parameters:**

obj | The object to bring to the last position. Must be contained in the set. |

remove(SimObject objects...)

Remove the given objects from the set.

**Parameters:**

objects | The objects to remove from the set. |

reorderChild(SimObject child1, SimObject child2)

Make sure child1 is ordered right before child2 in the set.

**Parameters:**

child1 | The first child. The object must already be contained in the set. |

child2 | The second child. The object must already be contained in the set. |

sort(string callbackFunction)

Sort the objects in the set using the given comparison function.

**Parameters:**

callbackFunction | Name of a function that takes two object arguments A and B and returns -1 if A is less, 1 if B is less, and 0 if both are equal. |