---
title: OSOrderedSet
framework: driverkit
role: symbol
role_heading: Class
path: driverkit/osorderedset
---

# OSOrderedSet

OSOrderedSet provides an ordered set store of objects.

## Declaration

```occ
class OSOrderedSet;
```

## Overview

Overview OSOrderedSet is a container for Libkern C++ objects (those derived from OSMetaClassBase, in particular OSObject). Storage and access follow ordered set logic. A given object is stored in the set only once, but you can: Define a sorting function for automated ordering (upon addition only) Manually insert new objects in the set (overriding sorting) Add and remove objects in the set Test whether the set contains a particular object Get the object stored at a particular index. Note that automated ordering is performed only upon addition of objects and depends on the existing objects being properly sorted. There is no function to re-sort the contents of an OSOrderedSet or to change the ordering function. In general, you should either use the one ordered-insertion function, or the indexed-insertion functions, and not mix the two. As with all Libkern collection classes, OSOrderedSet retains objects added to it, and releases objects removed from it. An OSOrderedSet also grows as necessary to accommodate new objects, unlike Core Foundation collections (it does not, however, shrink). Use Restrictions With very few exceptions in the I/O Kit, all Libkern-based C++ classes, functions, and macros are unsafe to use in a primary interrupt context. Consult the I/O Kit documentation related to primary interrupts for more information. OSOrderedSet provides no concurrency protection; it’s up to the usage context to provide any protection necessary. Some portions of the I/O Kit, such as IORegistryEntry, handle synchronization via defined member functions for setting properties.

## Topics

### Instance Methods

- [free](driverkit/osorderedset/free.md)
- [getFirstObject](driverkit/osorderedset/getfirstobject.md)
- [getLastObject](driverkit/osorderedset/getlastobject.md)
- [init](driverkit/osorderedset/init.md)
- [orderObject](driverkit/osorderedset/orderobject.md)
- [setFirstObject](driverkit/osorderedset/setfirstobject.md)
- [setLastObject](driverkit/osorderedset/setlastobject.md)
- [setObject](driverkit/osorderedset/setobject.md)

### Type Methods

- [withCapacity](driverkit/osorderedset/withcapacity.md)

## Relationships

### Inherits From

- [OSSet](driverkit/osset.md)

## See Also

### Data Types

- [IOCallOnceBlock](driverkit/iocallonceblock.md)
- [IOCallOnceFlag](driverkit/iocallonceflag.md)
- [IOCommand](driverkit/iocommand.md)
- [IOCommandPool](driverkit/iocommandpool.md)
- [IOCommandPoolPtr](driverkit/iocommandpoolptr.md)
- [IOCommandPtr](driverkit/iocommandptr.md)
- [IODMACommand](driverkit/iodmacommand.md)
- [IODMACommandSpecification](driverkit/iodmacommandspecification.md)
- [IODispatchAction](driverkit/iodispatchaction.md)
- [IOHistogramReporter_IVars](driverkit/iohistogramreporter_ivars.md)
- [IOReportLegendEntry](driverkit/ioreportlegendentry.md)
- [IOReporter_IVars](driverkit/ioreporter_ivars.md)
- [IOSimpleReporter_IVars](driverkit/iosimplereporter_ivars.md)
- [IOStateReporter_IVars](driverkit/iostatereporter_ivars.md)
- [IOStateReporter_valueSelector](driverkit/iostatereporter_valueselector.md)
