Index

RBFragmentedArray.swift

Classes


RBFragmentedArray

Properties

The first (lowest) index of an object stored in the array. Returns 'NSNotFound' if no index exists.
public var firstIndex Int { get }

The last (highest) index of an object stored in the array. Returns 'NSNotFound' if no index exists.
public var lastIndex Int { get }

The number of objects stored in the array.
public var count Int { get }

The first object (with the lowest index) stored in the array.
public var firstObject Any? { get }

The last object (with the highest index) stored in the array.
public var lastObject Any? { get }

An array of indexes for which objects are stored in the array.
public var indexes [Int] { get }

Functions

Sets the object stored in the array at a given index.
@param object : The object to store. If object is nil the object at index will be removed.
@param index : The index at which to store the object.
public func setObject(_ object: Any?, at index: Int)

Removes the object stored at the given index.
@param index : The index at which the object is stored.
public func removeObject(at index: Int)

Removes all of the objects stored in the array.
public func removeAllObjects()

Retrieves the object stored at the given index.
@param index : The index to retrieve the object for.
@returns The object stored at the index, or nil if there was no object found.
public func object(at index: Int) -> Any?

Enumerates each object in the array for removal.
@param block : The block to call on each object, if the block returns true the object is removed.
public func enumerateObjectRemoval(usingBlock block: @escaping (_ obj: Any, _ idx: Int) -> Bool)

Enumerates the objects stored in the array.
@param block : The block to call on each object in the array.
public func enumerateObjects(usingBlock block: @escaping (_ obj: Any, _ idx: Int) -> Void)

Determines whether an object is stored at the given index.
@param index : The index at which to check if an object is stored.
@returns Whether or not an object is stored at the given index.
public func hasIndex(_ index: Int) -> Bool