# Indices or not indices

(The content of this page original came from the Oct. 23, 2003, version of the page by the same name in the pre-2007 version of the sbml.org website. The last person to change that page was Ben Kovitz. The content below is unchanged except for formatting.)

An issue regarding arrays: Do we refer to elements of arrays via numerical indices or some other way?

## Three distinct concepts

Here we distinguish three concepts that are usually bundled together in the notion of an "array":

The collection concept gives you the ability to refer to a bunch (i.e. a collection) of elements as "one thing", typically when a program needs to pass the whole bunch at once, e.g. as an argument to a function.

The indexing concept is about how you refer to an element. Indexing is by integer: there's a 0th element, a 1st element, a 2nd element, and so on. Indexing is often a very natural way to refer to elements inside a collection when the collection is in some way distributed evenly in space or time. Without a naturally one-dimensional physical axis, though, the numbers can become arbitrary. For example, introducing numbers to a dictionary lookup (looking up elements by name) adds an unnecessary step of complexity.

The iteration concept is about the order in which you access, store, or modify elements, usually with the implicit understanding that all the elements are to be dealt with. For example, in an Ordered Collection in Small Talk, iteration is intended to start at the first element and proceed successively to the last element (or sometimes backward, from last to first). Iteration over a Sorted Collection proceeds from the smallest element to the largest (or, again, you can go backward). Iteration over Sets and Bags has no defined order: i.e. the definitions of these kinds of collections explicitly state that order is undefined or irrelevant.

Note that at the level of implementation, many different sorts of collection are usually implemented as arrays, because computers are so fast at looking things up by offset from an address. However, as SBML is a description language, we can make it as rich and nuanced for modelers as we like--whatever form of description is most powerful or economical for our purposes.