Core Foundation Collection Services
You often need your program to hold onto data it encounters so that later it can use the data or pass it around to other clients. When your code (or some client code) needs that piece of stored data, it locates and retrieves the data using a well-understood scheme. The objects provided by Core Foundation Collection Services--collection objects--help you store, organize, and retrieve data of virtually all types.
In addition to organizing data for quick and accurate retrieval, collection objects bring several benefits to programming:
-
They allow you to customize the automatic behavior of collections to suit the type of data stored (Collection Customization).
-
They can apply program-defined logic to all data elements in a collection (Applying Program-Defined Functions to Collections).
-
They can ensure the uniqueness of data elements added to a collection.
-
They enable you to modify (add, insert, delete, sort, and so forth) the data elements in a collection.
-
They are essential to Core Foundation property lists, along with string objects (CFString), number objects (CFNumber and CFBoolean), and data objects (CFData). See "Core Foundation Property List Services" for details.
Collection Services defines several types of collection objects:
-
Array objects (of the opaque type CFArray) organize elements by sequential position.
-
Dictionary objects (of the opaque type CFDictionary) identify elements through an arbitrary key.
-
Set objects (of the opaque type CFSet) are a collection of elements in which there are no duplicates.
-
Bag objects (of the opaque type CFBag) are a collection of elements in which there can be duplicates.
-
Tree objects (of the opaque type CFTree) organize elements in hierarchical (parent-children) relationships.
In addition, Collection Services includes data objects of the opaque type CFData. Although data objects are not true collections, they do hold arbitrary "collections" of bytes and are thus useful for storing binary data. They are also one of the property-list object types.
Headers
: