getCurrentKey

getCurrentKey(ordinal: Integer): Any;

The getCurrentKey method of the Iterator class is an abstract method that is implemented only by dictionary iterators.

This method retrieves the keys from an iterator while iterating through the dictionary and returns the value of a single key at the current position of the iterator in the associated dictionary.

This method can be used to access the keys of an external key dictionary or to access key properties in a member key dictionary directly from the iterator without having to access the member object itself.

The ordinal parameter specifies the relative key by ordinal position of the key in the associated dictionary and should be a number in the range 1 through the number of keys in the dictionary.

When you use this method for filtering based on key conditions or populating list views with key data, judicious use of this method may result in performance improvements. (Performance improvements occur when you can avoid fetching objects from the server to access key properties.)

This method can be used as an alternative to the getIteratorKeys of the Dictionary class to avoid share locking the associated dictionary on each call.

There are locking behavior differences between the Iterator class getCurrentKey method and the Dictionary class getIteratorKeys method. Both methods apply shared locks to a collection but the getCurrentKey method applies significantly fewer locks to the collection than the getIteratorKeys method.

The getCurrentKey method applies a shared lock to the collection once; this lock is applied the first time the method is called.

The getIteratorKeys method applies a shared lock on every iteration, as opposed to once on the first call.

The following example shows the difference in the number of locks applied by each method on a collection that contains 10 objects. Using the:

For details, see "Locking Behavior", in the Design Tips for Better Performance White Paper.