array
A sequence of same-sized slots stored one after another in a single block of memory, so any slot can be reached by its index directly.
In more detail
Because the address of slot k is the start address plus k times the slot size, reading any element by index takes constant time. The price is that inserting or deleting near the front shifts everything after it. Most languages build their growable lists on arrays, and some, such as JavaScript, use the name array for such a flexible list of values.
Examples
Python's list is an array of pointers; array.array('i', ...) stores raw four-byte integers.var octets [4]byteRelated terms
- contiguous memory — Memory laid out as one unbroken block, with each item directly after the previous one.
- memory address — The number that identifies one byte's position in memory, much like a house number on a very long street.
- dynamic array — An array that grows on demand by allocating a larger block and copying the existing items across when it runs out of room.
- array.array — Python's standard-library typed array, which stores numbers of one type as raw binary values instead of as full Python objects.
- random access — Reaching any element of a sequence directly by its position, in the same time whatever the position.
- collection — An object that holds a group of items, such as a list, dictionary, set or array.
- List<T> — The .NET growable array: items keep their order, reading by index is constant time, and searching by value walks the whole list.
- collection expression — C# square-bracket syntax such as [1, 2, 3] or [] that builds whatever collection type the target declares.
- slice — A flexible, growable view over a list of values of one type, written like []string, and Go's everyday list.
- map — A Go collection that stores values by key, such as service name to port number, and looks them up quickly.
- TypedArray — An array-like view, such as Uint8Array, that reads and writes numbers of one fixed type in an ArrayBuffer.
- object — A single thing created from a class or other type, holding its own values and able to run the type's methods.
Taught in
- Hash Tables: Chaining, Open Addressing And Load Factor — Algorithms & Data Structures for Working Engineers
- Arrays: Contiguous Memory And Constant-Time Access — Algorithms & Data Structures for Working Engineers
- Deques And Ring Buffers — Algorithms & Data Structures for Working Engineers
- Choosing The Right Sequence — Algorithms & Data Structures for Working Engineers
- Binary Search And Its Invariant — Algorithms & Data Structures for Working Engineers
- Heaps And Priority Queues — Algorithms & Data Structures for Working Engineers
- The C# Language: Types, Variables, and Flow Control — Modern .NET Core, C# & Enterprise Microservices
- Collections, Generics, and LINQ — Modern .NET Core, C# & Enterprise Microservices
- Arrays, Slices, and Maps — Concurrent Systems Programming with Go
- Node.js Process Architecture: Memory & Heap Spaces — Node.js Internals & Backend Services
- Stream Mechanics: Readable Streams & Flowing Modes — Node.js Internals & Backend Services