A dictionary which enumerates keys according to their natural sorted order. More...
#import <CHSortedDictionary.h>


Public Member Functions | |
| (NSArray *) | - allKeys [implementation] |
| Returns an array containing the receiver's keys in sorted order. | |
| (BOOL) | - lockBeforeDate: [implementation] |
| Attempts to acquire a lock before a given time and returns whether the attempt was successful. | |
| (BOOL) | - tryLock [implementation] |
| Attempts to acquire a lock and immediately returns whether the attempt was successful. | |
| (void) | - unlock [implementation] |
| Relinquishes a previously acquired lock. | |
Querying Contents | |
| (id) | - firstKey |
| Returns the minimum key in the receiver, according to natural sorted order. | |
| (id) | - lastKey |
| Returns the maximum key in the receiver, according to natural sorted order. | |
| (NSMutableDictionary *) | - subsetFromKey:toKey:options: |
| Returns a new dictionary containing the entries for keys delineated by two given objects. | |
Locks and Synchronization | |
| (void) | - lock |
| Attempts to acquire a lock, blocking a thread's execution until the lock can be acquired. | |
A dictionary which enumerates keys according to their natural sorted order.
The following additional operations are provided to take advantage of the ordering:
Key-value entries are inserted just as in a normal dictionary, including replacement of values for existing keys, as detailed in -[NSMutableDictionary setObject:forKey:]. However, an additional CHSortedSet structure is used in parallel to sort the keys, and keys are enumerated in that order.
Implementations of sorted dictionaries (aka "maps") in other languages include the following:
| - (NSArray *) allKeys | [implementation] |
Returns an array containing the receiver's keys in sorted order.
| - (id) firstKey |
Returns the minimum key in the receiver, according to natural sorted order.
nil if the receiver is empty.| - (id) lastKey |
Returns the maximum key in the receiver, according to natural sorted order.
nil if the receiver is empty.| - (void) lock |
Attempts to acquire a lock, blocking a thread's execution until the lock can be acquired.
An application protects a critical section of code by requiring a thread to acquire a lock before executing the code. Once the critical section is past, the thread relinquishes the lock by invoking unlock.
Reimplemented from <NSLocking>.
Attempts to acquire a lock before a given time and returns whether the attempt was successful.
The thread is blocked until the receiver acquires the lock or limit is reached.
| limit | The time limit for attempting to acquire a lock. |
YES if the lock was acquired before limit, otherwise NO.Reimplemented from <CHLockable>.
| - (NSMutableDictionary *) subsetFromKey: | (id) | start | ||
| toKey: | (id) | end | ||
| options: | (CHSubsetConstructionOptions) | options | ||
Returns a new dictionary containing the entries for keys delineated by two given objects.
The subset is a shallow copy (new memory is allocated for the structure, but the copy points to the same objects) so any changes to the objects in the subset affect the receiver as well. The subset is an instance of the same class as the receiver.
| start | Low endpoint of the subset to be returned; need not be a key in receiver. | |
| end | High endpoint of the subset to be returned; need not be a key in receiver. | |
| options | A combination of CHSubsetConstructionOptions values that specifies how to construct the subset. Pass 0 for the default behavior, or one or more options combined with a bitwise OR to specify different behavior. |
nil, all keys in the receiver are included. (Equivalent to calling -copy.)nil, keys that match or follow start are included.nil, keys that match or preceed start are included.| - (BOOL) tryLock | [implementation] |
Attempts to acquire a lock and immediately returns whether the attempt was successful.
YES if the lock was acquired, otherwise NO.Reimplemented from <CHLockable>.
| - (void) unlock | [implementation] |
Relinquishes a previously acquired lock.
Reimplemented from <CHLockable>.
1.6.2