<!--
{
  "documentType" : "article",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/collections",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "Collections"
}
-->

# Collections

Store and organize data using arrays, dictionaries, sets, and other data structures.

## Topics

### Arrays and Dictionaries

[`Array`](/documentation/Swift/Array)

An ordered, random-access collection.

[`Dictionary`](/documentation/Swift/Dictionary)

A collection whose elements are key-value pairs.

[`InlineArray`](/documentation/Swift/InlineArray)

A fixed-size array.

### Sets

[`Set`](/documentation/Swift/Set)

An unordered collection of unique elements.

[`OptionSet`](/documentation/Swift/OptionSet)

A type that presents a mathematical set interface to a bit set.

### Ranges

Create a collection of all the values in a range by using the half-open (`..<`) and
closed (`...`) range operators.

[`..<(_:_:)`](/documentation/Swift/Comparable/.._(_:_:))

Returns a half-open range that contains its lower bound but not its upper
bound.

[`Range`](/documentation/Swift/Range)

A half-open interval from a lower bound up to, but not including, an upper
bound.

[`RangeSet`](/documentation/Swift/RangeSet)

A set of values of any comparable type, represented by ranges.

[`...(_:_:)`](/documentation/Swift/Comparable/...(_:_:))

Returns a closed range that contains both of its bounds.

[`ClosedRange`](/documentation/Swift/ClosedRange)

An interval from a lower bound up to, and including, an upper bound.

### Strides

Create a stride that steps over values between two boundaries using the `stride(from:to:by:)`
and `stride(from:through:by:)` functions.

[`stride(from:to:by:)`](/documentation/Swift/stride(from:to:by:))

Returns a sequence from a starting value to, but not including, an end
value, stepping by the specified amount.

[`stride(from:through:by:)`](/documentation/Swift/stride(from:through:by:))

Returns a sequence from a starting value toward, and possibly including, an end
value, stepping by the specified amount.

### Special-Use Collections

These collections can store zero, one, or many of the same element.

[`repeatElement(_:count:)`](/documentation/Swift/repeatElement(_:count:))

Creates a collection containing the specified number of the given element.

[`CollectionOfOne`](/documentation/Swift/CollectionOfOne)

A collection containing a single element.

[`EmptyCollection`](/documentation/Swift/EmptyCollection)

A collection whose element type is `Element` but that is always empty.

[`KeyValuePairs`](/documentation/Swift/KeyValuePairs)

A lightweight collection of key-value pairs.

[`DictionaryLiteral`](/documentation/Swift/DictionaryLiteral)

### Dynamic Sequences

[`sequence(first:next:)`](/documentation/Swift/sequence(first:next:))

Returns a sequence formed from `first` and repeated lazy applications of
`next`.

[`sequence(state:next:)`](/documentation/Swift/sequence(state:next:))

Returns a sequence formed from repeated lazy applications of `next` to a
mutable `state`.

### Joint Iteration

[`zip(_:_:)`](/documentation/Swift/zip(_:_:))

Creates a sequence of pairs built out of two underlying sequences.

### Advanced Collection Topics

  <doc://com.apple.Swift/documentation/Swift/sequence-and-collection-protocols>

  <doc://com.apple.Swift/documentation/Swift/supporting-types>

  <doc://com.apple.Swift/documentation/Swift/managed-buffers>



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)