ListBase
open class ListBase : DataValue
Base class for strongly-typed lists.
-
Construct a new list with a
length
of zero and specified initialcapacity
. A list can expand in length beyond its initial capacity, but best performance will be obtained if the initial capacity is close to (and not less than) the list’s maximum length.Declaration
Swift
public init(capacity: Int)
Parameters
capacity
Initial capacity.
-
An ordering function for the item type of this list.
Declaration
Swift
open var comparer: Comparer { get }
-
The data type for this list.
Declaration
Swift
override open var dataType: DataType { get }
-
An equality function for the item type of this list.
Declaration
Swift
open var equality: Equality { get }
-
true
if this list contains no items.Declaration
Swift
open var isEmpty: Bool { get }
-
The number of items in this list.
Declaration
Swift
open var length: Int { get }
-
Remove an item from the specified index in this list.
Declaration
Swift
open func remove(at index: Int)
Parameters
index
Index of the item to be removed.
-
Remove all items from this list.
Declaration
Swift
open func removeAll()
-
Remove the first item (if any) from this list.
Declaration
Swift
open func removeFirst()
-
Remove the last item (if any) from this list.
Declaration
Swift
open func removeLast()
-
Remove a range of items from this list.
Declaration
Swift
open func removeRange(start: Int, end: Int)
Parameters
start
Starting index (inclusive) for items to be removed.
end
Ending index (exclusive) for items to be removed.
-
Reverse the order of the items in this list.
Declaration
Swift
open func reverse()
-
Sort the items in this list, using the
comparer
property for ordering.Declaration
Swift
open func sort()
-
Sort the items in this list.
Declaration
Swift
open func sortWith(comparer: Comparer)
Parameters
comparer
Comparer for ordering.
-
Declaration
Swift
open func toDynamic() -> ListBase?
Return Value
a dynamic representation of this list (
DataValueList
,ComplexValueList
, orEntityValueList
), ornil
if there is no dynamic representation available. -
Declaration
Swift
override open func toString() -> String
Return Value
a string representation of this list.
-
The underlying untyped list. Use with care, avoiding the addition of objects with an incorrect item type.
Declaration
Swift
open var untypedList: UntypedList { get }
-
Base function for validating the item’s value before adding it to the list. Validate is needed in some ListBase types, for exampe in the case of ByteList, where a value out of the ByteValue type’s valid range can be added, because ByteList accepts Int instead of Byte. With a proper overwrite of this function in the given BaseList class ensures, that only a valid value Int (-128 - +127 in this case) can be added to the list.
Declaration
Swift
open func validate(_ value: AnyObject?) -> AnyObject?
Parameters
value
The value to be validated.
Return Value
The
value
without modification.