---
title: NSMutableOrderedSet
framework: foundation
role: symbol
role_heading: Class
path: foundation/nsmutableorderedset
---

# NSMutableOrderedSet

A dynamic, ordered collection of unique objects.

## Declaration

```swift
class NSMutableOrderedSet
```

## Overview

Overview NSMutableOrderedSet objects are not like C arrays. That is, even though you may specify a size when you create a mutable ordered set, the specified size is regarded as a “hint”; the actual size of the set is still 0. This means that you cannot insert an object at an index greater than the current count of an set. For example, if a set contains two objects, its size is 2, so you can add objects at indices 0, 1, or 2. Index 3 is illegal and out of bounds; if you try to add an object at index 3 (when the size of the array is 2), NSMutableOrderedSet raises an exception.

## Topics

### Creating a Mutable Ordered Set

- [init(capacity:)](foundation/nsmutableorderedset/init(capacity:).md)
- [init()](foundation/nsmutableorderedset/init().md)

### Adding, Removing, and Reordering Entries

- [add(_:)](foundation/nsmutableorderedset/add(_:).md)
- [add(_:count:)](foundation/nsmutableorderedset/add(_:count:).md)
- [addObjects(from:)](foundation/nsmutableorderedset/addobjects(from:).md)
- [insert(_:at:)](foundation/nsmutableorderedset/insert(_:at:)-7qg51.md)
- [insert(_:at:)](foundation/nsmutableorderedset/insert(_:at:)-3ncnm.md)
- [remove(_:)](foundation/nsmutableorderedset/remove(_:).md)
- [removeObject(at:)](foundation/nsmutableorderedset/removeobject(at:).md)
- [removeObjects(at:)](foundation/nsmutableorderedset/removeobjects(at:).md)
- [removeObjects(in:)](foundation/nsmutableorderedset/removeobjects(in:)-8h2kh.md)
- [removeObjects(in:)](foundation/nsmutableorderedset/removeobjects(in:)-9jkis.md)
- [removeAllObjects()](foundation/nsmutableorderedset/removeallobjects().md)
- [replaceObject(at:with:)](foundation/nsmutableorderedset/replaceobject(at:with:).md)
- [replaceObjects(at:with:)](foundation/nsmutableorderedset/replaceobjects(at:with:).md)
- [replaceObjects(in:with:count:)](foundation/nsmutableorderedset/replaceobjects(in:with:count:).md)
- [setObject(_:at:)](foundation/nsmutableorderedset/setobject(_:at:).md)
- [moveObjects(at:to:)](foundation/nsmutableorderedset/moveobjects(at:to:).md)
- [exchangeObject(at:withObjectAt:)](foundation/nsmutableorderedset/exchangeobject(at:withobjectat:).md)
- [filter(using:)](foundation/nsmutableorderedset/filter(using:).md)

### Sorting Entries

- [sort(using:)](foundation/nsmutableorderedset/sort(using:).md)
- [sort(comparator:)](foundation/nsmutableorderedset/sort(comparator:).md)
- [sort(options:usingComparator:)](foundation/nsmutableorderedset/sort(options:usingcomparator:).md)
- [sortRange(_:options:usingComparator:)](foundation/nsmutableorderedset/sortrange(_:options:usingcomparator:).md)

### Combining and Recombining Entries

- [intersect(_:)](foundation/nsmutableorderedset/intersect(_:).md)
- [intersectSet(_:)](foundation/nsmutableorderedset/intersectset(_:).md)
- [minus(_:)](foundation/nsmutableorderedset/minus(_:).md)
- [minusSet(_:)](foundation/nsmutableorderedset/minusset(_:).md)
- [union(_:)](foundation/nsmutableorderedset/union(_:).md)
- [unionSet(_:)](foundation/nsmutableorderedset/unionset(_:).md)

### Initializers

- [init(coder:)](foundation/nsmutableorderedset/init(coder:).md)
- [init(objects:count:)](foundation/nsmutableorderedset/init(objects:count:).md)

## Relationships

### Inherits From

- [NSOrderedSet](foundation/nsorderedset.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [ExpressibleByArrayLiteral](swift/expressiblebyarrayliteral.md)
- [Hashable](swift/hashable.md)
- [NSCoding](foundation/nscoding.md)
- [NSCopying](foundation/nscopying.md)
- [NSFastEnumeration](foundation/nsfastenumeration.md)
- [NSMutableCopying](foundation/nsmutablecopying.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [NSSecureCoding](foundation/nssecurecoding.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)
- [Sequence](swift/sequence.md)

## See Also

### Specialized Sets

- [NSCountedSet](foundation/nscountedset.md)
- [NSOrderedSet](foundation/nsorderedset.md)
