Skip to content

Instantly share code, notes, and snippets.

@mtnlife999
Created September 18, 2013 18:31
Show Gist options
  • Save mtnlife999/6613428 to your computer and use it in GitHub Desktop.
Save mtnlife999/6613428 to your computer and use it in GitHub Desktop.
*!
@header CFArray
CFArray implements an ordered, compact container of pointer-sized
values. Values are accessed via integer keys (indices), from the
range 0 to N-1, where N is the number of values in the array when
an operation is performed. The array is said to be "compact" because
deleted or inserted values do not leave a gap in the key space --
the values with higher-numbered indices have their indices
renumbered lower (or higher, in the case of insertion) so that the
set of valid indices is always in the integer range [0, N-1]. Thus,
the index to access a particular value in the array may change over
time as other values are inserted into or deleted from the array.
Arrays come in two flavors, immutable, which cannot have values
added to them or removed from them after the array is created, and
mutable, to which you can add values or from which remove values.
Mutable arrays can have an unlimited number of values (or rather,
limited only by constraints external to CFArray, like the amount
of available memory).
As with all CoreFoundation collection types, arrays maintain hard
references on the values you put in them, but the retaining and
releasing functions are user-defined callbacks that can actually do
whatever the user wants (for example, nothing).
Computational Complexity
The access time for a value in the array is guaranteed to be at
worst O(lg N) for any implementation, current and future, but will
often be O(1) (constant time). Linear search operations similarly
have a worst case complexity of O(N*lg N), though typically the
bounds will be tighter, and so on. Insertion or deletion operations
will typically be linear in the number of values in the array, but
may be O(N*lg N) clearly in the worst case in some implementations.
There are no favored positions within the array for performance;
that is, it is not necessarily faster to access values with low
indices, or to insert or delete values with high indices, or
whatever.
*/
#if !defined(__COREFOUNDATION_CFARRAY__)
#define __COREFOUNDATION_CFARRAY__ 1
#include <CoreFoundation/CFBase.h>
CF_EXTERN_C_BEGIN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment