Vector
A vector is an ordered sequence of elements treated as a single object, with its size fixed or resizable depending on the context.
Learn C++ by Example
std::vector is the C++ standard library's dynamically sized contiguous sequence container.
- How it is used
- Uses vectors to store, traverse, display, query, and manipulate sequences while introducing ranges, algorithms, and lambdas.
- How deep it goes
- Explains initialization, traversal, insertion, nesting, const access, and selected move behavior, while deferring full iterator and value-category details.
- Examples
- Uses a one-element display, Pascal’s triangle, nested rows, and a console race containing runtime-sized collections.
- What you can do after
- Build it from scratch by creating vectors, filling and displaying them, generating nested data, and selecting copying or moving insertion.
100 C++ Mistakes and How to Avoid Them
A vector is a resizable sequence container whose elements are stored in contiguous memory.
- How it is used
- Uses vectors as safer collection alternatives to arrays and variable argument lists in C++.
- How deep it goes
- Works through constructing, appending, reserving and traversing vectors, without detailing their implementation.
- Examples
- Illustrates vectors with initialized Person objects and a templated sum for integer and double values.
- What you can do after
- Apply std::vector to replace awkward arrays or type-unsafe variable argument lists.
Read how 100 C++ Mistakes and How to Avoid Them explains vector →
Grokking Data Structures
A dynamic array is an array-like data structure whose storage can grow or shrink as elements are added or removed.
- How it is used
- Provides indexed storage for collections whose number of elements changes substantially.
- How deep it goes
- Explains fixed-size backing storage, doubling, quarter-full shrinking, and amortized costs rather than treating resizing as free.
- Examples
- Uses changing e-commerce orders and a stack push that fills its backing array.
- What you can do after
- Build it from scratch using a static array with doubling on growth and halving when quarter-full.
Code Like a Pro in Rust
- How it is used
- Uses Vec as the default general-purpose container for resizable sequences in Rust.
- How deep it goes
- Explains slice coercion, borrowing, capacity growth, and copying internals, while deferring custom allocator details.
- Examples
- Demonstrates a rejected resize during a slice borrow, capacity growth during pushes, and a release-mode copying benchmark.
- What you can do after
- Apply it via Rust’s Vec to manage sequences, plan capacity, and select copying and collection strategies.
Object-Oriented Software Design in C++
A dynamically sized sequential container that stores elements in contiguous order and manages an internal dynamically allocated array.
- How it is used
- Uses vectors to manage resizable collections in catalogues and appointment lists while illustrating their operational costs.
- How deep it goes
- Explains storage resizing, core operations, object copying, and a pointer-based alternative, but does not quantify complexity.
- Examples
- Demonstrates vectors through book catalogues, appointment dates, insertion, removal, printed output, and instrumented copy-constructor traces.
- What you can do after
- Evaluate vector usage and diagnose performance surprises caused by storing objects and triggering hidden copies.
Read how Object-Oriented Software Design in C++ explains vector →
Clojure: The Essential Reference
A vector is an ordered, indexed Clojure collection that stores values as sequential elements.
- How it is used
- Uses vectors for ordered, indexed values that support direct access and efficient tail operations.
- How deep it goes
- Explains operations, sequence behavior, and vec's input contract and array caveat, without detailing vector implementation internals.
- Examples
- Shows indexed access and updates, positional contains? results, and vec conversion with a Java-array aliasing example.
- What you can do after
- Apply it via Clojure's indexed operations and vec while distinguishing vectors from sequences and guarding against array aliasing.
Rust in Action: Systems programming concepts and techniques
A vector is a dynamically resizable, ordered collection of elements.
- How it is used
- Uses vectors to collect fields and store matching lines with their surrounding context.
- How deep it goes
- Explains growable lists through a two-pass example, nested types, and capacity hints.
- Examples
- Uses penguin CSV records and a text-search utility that prints numbered context lines.
- What you can do after
- Apply it using Rust’s Vec<T> to collect fields and organize lines around search matches.
Read how Rust in Action: Systems programming concepts and techniques explains vector →
Modern C, Third Edition
A dynamic array is an array-like data structure whose storage can be allocated or resized during program execution.
- How it is used
- Uses dynamic storage to implement a circular buffer whose capacity can be raised or lowered during execution.
- How deep it goes
- Explains representation, initialization, destruction, access, resizing, allocation failure, and wrapped-data movement.
- Examples
- Demonstrates a double-valued circular buffer with initialization, element access, resizing, allocation failure, and destruction.
- What you can do after
- Builds a resizable circular buffer and preserves valid ownership across allocation, resizing, access, and destruction.
Deep Learning with R, Third Edition
A vector is a quantity represented by an ordered collection of components and interpreted geometrically as a directed displacement or point relative to an origin.
- How it is used
- Defines vectors as the basic one-axis representation for numeric data and geometric points in neural-network computation.
- How deep it goes
- Explains rank, dimensionality, representations, geometric addition, and transformations, but stops short of formal derivations.
- Examples
- Uses an R five-entry array, vector addition for translation, and matrix products for rotation, scaling, and linear transformation.
- What you can do after
- Evaluate vector representations, distinguish rank from dimensionality, and interpret basic tensor operations geometrically.
Read how Deep Learning with R, Third Edition explains vector →
Julia as a Second Language
Vector is Julia's parametric one-dimensional array type for elements of a specified type.
- How it is used
- Represents ordered one-dimensional data for calculations, summaries, sorting, and elementwise transformations.
- How deep it goes
- Explains construction, indexing, column-row distinctions, common functions, mutation conventions, and elementwise arithmetic, while deferring deeper multidimensional work.
- Examples
- Uses pizza quantities and prices to demonstrate construction, averaging, sorting, taxation, elementwise multiplication, and total revenue.
- What you can do after
- Apply Julia vectors via indexing, sum, length, sort!, and dotted arithmetic to calculate and transform ordered data.
Learn Rust in a Month of Lunches
A vector is Rust's growable, heap-allocated sequence type whose elements share a type.
- How it is used
- Holds ordered collections whose size needs to change during program execution.
- How deep it goes
- Explains construction, element types, slicing, capacity, growth, and preallocation through focused examples.
- Examples
- Uses name vectors, integer vectors, vector slices, nested vectors, and capacity-printing programs.
- What you can do after
- Build vectors with Vec::new, vec!, push, explicit types, slicing, and Vec::with_capacity.
Grokking Machine Learning, Second Edition
A vector is an ordered sequence of numerical entries representing a mathematical quantity or data point.
- How it is used
- Represents images, labels, sentences, and classifier outputs as numerical inputs or predictions.
- How deep it goes
- Explains vectors through word counts, pixel flattening, label encoding, and classifier outputs without developing vector operations.
- Examples
- Uses MNIST pixel and digit-label vectors alongside three-word sentence vectors based on word appearance counts.
- What you can do after
- Apply vectors via NumPy and Keras by reshaping images, encoding labels, and reading classifier predictions.
Read how Grokking Machine Learning, Second Edition explains vector →
Embedded Software with Rust
A vector is Rust's owned, growable vector type for storing elements contiguously on dynamically allocated storage.
- How it is used
- Stores runtime-growing diagnostic messages for later iteration and reporting in firmware.
- How deep it goes
- Explains growth, reallocation, preallocation, and fallible reservation through allocation behavior and code examples.
- Examples
- Uses a growing event log and compares pushing 100 samples with reserving capacity for them first.
- What you can do after
- Apply it via Vec::with_capacity and try_reserve to manage growth and handle allocation failure.
The Coder Cafe
A dynamic array is a resizable array that may allocate extra capacity to support insertions efficiently.
- How it is used
- Supports choosing a collection representation by comparing indexed access, resizing, insertion, and memory-layout tradeoffs.
- How deep it goes
- Compares memory layout, access, flexibility, and insertion complexity, including average and resizing worst cases.
- Examples
- Uses ArrayList, std::vector, and Go slices as concrete dynamic-array implementations.
- What you can do after
- Evaluate whether a dynamic array or linked list better fits a collection’s access, insertion, growth, and memory requirements.
Also covered in
- Just Use Postgres!
- Grokking Software ArchitectureIn early access (MEAP)
- GPU Programming with TritonIn early access (MEAP)
- Rust Servers, Services, and Apps
- Refactoring to Rust
- Machine Learning Algorithms in Depth
- Build a Robo-Advisor with Python (From Scratch)
- High Performance Unity Game DevelopmentIn early access (MEAP)
What to know first
- arrayAn array is an ordered collection of elements organized in one or more dimensions and accessible by position or index.
- iteratorAn iterator is an object or abstraction that provides successive values from a collection or other data source through a traversal interface.
- referenceA reference is an indirect value, binding, or relationship that identifies or provides access to another object, value, resource, or source.
- initializerAn initializer is a function, declaration, or language construct that establishes an initial value or state for an object, value, or computation.
Related concepts
- arraykind of · An array is an ordered collection of elements organized in one or more dimensions and accessible by position or index.
- collectproduced by · Collect is an operation that gathers produced values or records into a collection or other result.
- fixed-size arrayimplements · A fixed-size array is an indexed collection whose storage capacity or length is established when it is created and remains unchanged.
- listincludes · A list is an ordered collection of elements arranged in a sequence.
- shuffleproduced by · Shuffling is the random rearrangement of elements in a collection or sequence.
Questions about vector
What is vector?
A vector is an ordered sequence of elements treated as a single object, with its size fixed or resizable depending on the context.
Which Manning books explain vector?
Learn C++ by Example, 100 C++ Mistakes and How to Avoid Them, Grokking Data Structures, Code Like a Pro in Rust, Object-Oriented Software Design in C++, Clojure: The Essential Reference, Rust in Action: Systems programming concepts and techniques, Modern C, Third Edition and 6 more.
What should I know before learning vector?
Manning books that teach vector usually introduce array, iterator, reference and initializer first.
What kinds of vector are there?
Kinds of vector include list and all-zero vector.
What is vector a kind of?
Vector is a kind of array. An array is an ordered collection of elements organized in one or more dimensions and accessible by position or index.
What is vector also called?
Vector is also called vec or dynamic array.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.













