Tömb
A Wikipédiából, a szabad enciklopédiából.
A számítógéptudományban a tömb (array) egy olyan adatszerkezet, amely olyan elemek csoportja, melyeknek egy nevük van és indexelve vannak. A legtöbb programozási nyelvben minden egyes elemnek azonos aaaaaaaaadattípusa van és a tömb folytonosan helyezkedik el a számítógép memóriájában.
[szerkesztés] Tömbrendszer kereszthivatkozási lista
Programozási nyelv | Base index | Bound Check | Dimenzió | Dynamic |
---|---|---|---|---|
Ada | n | checked | n | init1 |
APL7 | 0 or 1 | checked | n | init1 |
assembly language | 0 | unchecked | 1 | no |
BASIC | 1 | unchecked | 1 | init1 |
C | 0 | unchecked | n2 | heap3,4 |
C++5 | 0 | unchecked | n2 | heap3 |
C# | 0 | checked | n2 | heap3,9 |
Common Lisp | 0 | checked | n | yes |
D | 0 | varies11 | n | yes |
FreeBASIC | n | checked | n | yes |
Fortran | n | varies12 | n | heap3 |
IDL | 0 | checked | n | yes |
Java5 | 0 | checked | 12 | heap3 |
Lua | 1 | checked | 12 | yes |
MATLAB | 1 | checked | n8 | yes |
Oberon-1 | 0 | checked | n | no |
Oberon-2 | 0 | checked | n | yes |
Pascal | n | checked | n | varies10 |
PERL | n | checked | 12 | yes |
PL/I | n | checked | ||
Python | 0 | checked | 12 | yes |
Ruby | 0 | checked | 12 | yes |
Scheme | 0 | checked | 12 | no |
Smalltalk5 | 1 | checked | 12 | yes6 |
Visual BASIC | n | checked | n | yes |
Windows PowerShell | 0 | checked | n2 | heap |
- Size can be chosen on initialization/declaration after which it is fixed.
- Allows arrays of arrays which can be used to emulate multi-dimensional arrays.
- Size can only be chosen when memory is allocated on the heap.
- C99 allows for variable size arrays – however there is almost no compiler available to support this new feature.
- This list is strictly comparing language features. In every language (even assembler) it is possible to provide improved array handling via add on libraries. This language has improved array handling as part of its standard library.
- The class Array is fixed-size, but OrderedCollection is dynamic.
- The indexing base can be 0 or 1, but is set for a whole "workspace".
- At least 2 dimensions (scalar numbers are 1×1 arrays, vectors are 1×n or n×1 arrays).
- Allows creation of fixed-size arrays in "unsafe" code, allowing for enhanced interoperability with other languages
- Varies by implementation. Newer implementations (FreePascal and Delphi) permit heap-based dynamic arrays.
- Behaviour can be tuned using compiler switches. As in DMD 1.0 bounds are checked in debug mode and unchecked in release mode for efficiency reasons.
- Almost all Fortran implementations offer bounds checking options via compiler switches. However by default, bounds checking is usually turned off for efficiency reasons.