Anonymous user
Array: Difference between revisions
m
Lost of English and some clarity fixes
mNo edit summary |
m (Lost of English and some clarity fixes) |
||
Line 1:
[[Category:Encyclopedia]]An '''array''' is a composite data type, in the [[Collections|collection]] category, that stores multiple values all of the same declared type. The stored values are called '''elements''' and are accessed by a tuple of indices. By using a variable indices, the array may be accessed for a not predetermined set of indices, during the run of the program. All indices of an array are [http://en.wikipedia.org/wiki/Total_order totally ordered].
An array
Arrays with more than one index are called '''multidimensional''' arrays. For example, a matrix is a two-dimensional array.
Basic operations defined on arrays are:
* Indexing
* Slicing
* Iteration of the
* Querying the bounds of array indices
* Operations on indices (next, previous, range etc)
* Array programming languages provide
Values of arrays are called '''array aggregates'''.
Multidimensional arrays
Each array index is bounded at run time. Further when▼
▲Each array index is bounded at run time. Further, when
# array is not associative
# each index is within the bounds (including the bounds)
then it is legal to access the array at the tuple of these indices.
The lower bound
For an empty array the lower bound of an index is greater than the upper bound. This causes the famous problem of declaring an empty array when the index type is a singleton (has only one value).
When bounds of all array indices are fixed, the array is said to be '''constrained'''. When some bounds are unknown until run time, the array is '''unconstrained'''. Non-associative, unconstrained arrays are usually passed to the subprograms with a "dope" attached to the array body. The dope contains the actual bounds of unconstrained array indices. Associative arrays carry some indexing structure with them, like a [[hash table]] etc.
The minimal size of a non-associative array is determined by the current bounds of its indices. In all regular programming languages, the size of such array can be set by the programmer at [[compile time]] or after. In many modern programming languages the size of the array may be computed and allocated at run time.
|