ComplexValueList
open class ComplexValueList : ListBase, Codable, ComplexValueOrList, Sequence, @unchecked Sendable
A list of item type ComplexValue.
-
Decode and initialize a new object instance
Declaration
Swift
public required init(from decoder: Decoder) throwsParameters
fromdecoder object which contains the original object’s serialized data in a container instance
-
Encode the object instance
Declaration
Swift
public func encode(to encoder: Encoder) throwsParameters
toencoder object which can be used to serialize the object’s data one by one into a container instance
-
Undocumented
Declaration
Swift
public subscript(index: Int) -> ComplexValue { get set } -
An immutable empty
ComplexValueList.Declaration
Swift
public static let empty: ComplexValueList -
trueif this list is a referece. Iftrue, thereadLinkwill be non-null, and this list will be empty.Declaration
Swift
final public var isReference: Bool -
An optional link that can be followed (by the caller) to fetch additional list items. If this complex list was produced via server-driven paging, then the server may have provided a next-link which can be followed to obtain more items.
Declaration
Swift
final public var nextLink: String? -
An optional link that can be followed (by the caller) to re-read this list.
Declaration
Swift
final public var readLink: String? -
Total number of items available in the server-side list, which may be greater than
lengthif the client requested an inlineDataQuery.count.Declaration
Swift
final public var totalCount: Int64? -
Construct a new list with
lengthof zero and optional 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
override public init(capacity: Int = (4 as Int))Parameters
capacityOptional initial capacity.
-
Add
itemto the end of this list.Declaration
Swift
public final func append(_ item: ComplexValue)Parameters
itemItem to be added.
-
Add all the items of
listto the end of this list.Declaration
Swift
public final func append(contentsOf list: ComplexValueList)Parameters
listItems to be added.
-
Add
itemto the end of this list. It is unusual for aComplexValueListto containnilitems, soaddis usually used.Declaration
Swift
open func appendOptional(_ item: ComplexValue?) -> ComplexValueListParameters
itemItem to be added, which might be
nil.Return Value
This list.
-
Declaration
Swift
open func applyPageSize(query: DataQuery) -> ComplexValueListParameters
queryData query whose
DataQuery.pageSizeis used for filtering.Return Value
A new list with at most
query.pageSizeinitial items of this list. The result’sComplexValueList.needsNextLinkwill betrueif the original list length exceeded the page size. -
Declaration
Swift
public final func copy() -> ComplexValueListReturn Value
A shallow copy of this list.
-
Declaration
Swift
override open func copyMutable() -> DataValueReturn Value
A clone of this value if it (together with all value subcomponents) is possibly mutable, or return
selfvalue if it (together with all value subcomponents) is definitely immutable. The resulting value might share mutable metadata with this query. -
The data type for this list.
Declaration
Swift
override open var dataType: DataType { get } -
See also
ComplexValue.equal.Declaration
Swift
open class func equal(a: ComplexValueList?, b: ComplexValueList?) -> BoolParameters
aFirst complex list.
bSecond complex list.
Return Value
trueif two complex lists have equal items. -
Declaration
Swift
public final func filter(_ predicate: @escaping (ComplexValue) -> Bool) -> ComplexValueListParameters
predicateFunction to be applied to each item of this list. Items matching this predicate will be returned in the new list.
Return Value
A new list which contains the items of this list that match a specified predicate function. Ordering is preserved.
-
Declaration
Swift
open func filterAndSort(query: DataQuery) throws -> ComplexValueListParameters
queryData query.
Return Value
A new list filtered by
filterWithQueryand then sorted bysortWithQuery. -
Declaration
Swift
open func filterWithQuery(_ query: DataQuery) throws -> ComplexValueListParameters
queryData query used for filtering.
Return Value
A new list with the items of this list, filtered by
query.queryFilter,query.derivedType,query.searchExpression(whichever of those is specified, if any). -
Throws
EmptyListExceptionif the list is empty.Declaration
Swift
public final func first() -> ComplexValueReturn Value
The first item in this list.
-
Convert array to list.
Declaration
Swift
open class func fromArray(_ array: Array<ComplexValue>) -> ComplexValueListParameters
arrayArray with source items.
Return Value
New list with items copied from
arrayparameter. -
Deprecated (renamed to
fromOptional). Convert array to list.Declaration
Swift
open class func fromNullable(_ array: Array<ComplexValue?>) -> ComplexValueListParameters
arrayArray with optional source items.
Return Value
New list with items copied from
arrayparameter. -
Convert array to list.
Declaration
Swift
open class func fromOptional(_ array: Array<ComplexValue?>) -> ComplexValueListParameters
arrayArray with optional source items.
Return Value
New list with items copied from
arrayparameter. -
Declaration
Swift
public final func includes(item: ComplexValue) -> BoolParameters
itemItem for comparison. Comparison uses the
equalityproperty, which would usually be expected to match the==operator for item typeComplexValue.Return Value
trueif this list containsitem. -
Declaration
Swift
public final func indexOf(item: ComplexValue, start: Int = (0 as Int)) -> IntParameters
itemItem for comparison. Comparison uses the
equalityproperty, which would usually be expected to match the==operator for item typeComplexValue.startZero-based starting index (search moves forwards from this index).
Return Value
First index in this list of
item, or-1if not found. -
Insert
iteminto this list, before the item (if any) atindex.Throws
ListIndexExceptionifindexis out of range (0 tolength).Declaration
Swift
public final func insert(at index: Int, item: ComplexValue)Parameters
indexZero-based index.
itemItem to be added.
-
Insert all items of
listinto this list, before the item (if any) atindex.Throws
ListIndexExceptionifindexis out of range (0 tolength).Declaration
Swift
public final func insert(at index: Int, contentsOf list: ComplexValueList)Parameters
indexZero-based index.
listList of items to be inserted.
-
Throws
ListIndexExceptionifindexis out of range (0 tolength- 1).Declaration
Swift
public final func item(at index: Int) -> ComplexValueParameters
indexZero-based index.
Return Value
The item in this list at the specified
index. -
Throws
EmptyListExceptionif the list is empty.Declaration
Swift
public final func last() -> ComplexValueReturn Value
The last item in this list.
-
Declaration
Swift
public final func lastIndexOf(item: ComplexValue, start: Int = (2147483647 as Int)) -> IntParameters
itemItem for comparison. Comparison uses the
equalityproperty, which would usually be expected to match the==operator for item typeComplexValue.startZero-based starting index (search moves backwards from this index).
Return Value
Last index in this list of
item, or-1if not found. -
Declaration
Swift
open func makeIterator() -> IndexingIterator<Array<ComplexValue>>Return Value
This list converted to a Swift iterator.
-
Declaration
Swift
open class func of(_ items: ComplexValue...) -> ComplexValueListParameters
rest_itemsItems for the resulting list.
Return Value
A new list of item type
ComplexValue, containing the specifieditems. -
Throws
ListIndexExceptionifindexis out of range (0 tolength- 1).Declaration
Swift
open func optionalItem(at index: Int) -> ComplexValue?Parameters
indexZero-based index.
Return Value
The item in this list at the specified
index, which might benil. It is unusual for aComplexValueListto containnilitems, sogetis usually used (althoughgetwill throw a fatal exception for anilitem). -
See also
copy,reverse.Declaration
Swift
open func reversed() -> ComplexValueListReturn Value
a reversed copy of this list.
-
Return a new
ComplexValueListthat shares theListBase.untypedListas thelistparameter. To ensure type safety, items inlistthat do not have the item typeComplexValuewill be removed.Declaration
Swift
open class func share(_ list: ListBase) -> ComplexValueListParameters
listList whose items will be shared by the resulting list.
Return Value
A new list of item type
ComplexValue, sharing the same items aslist. -
Return a new
ComplexValueListthat shares theListBase.untypedListof thelistparameter, including nulls. To ensure type safety, non-null items inlistthat do not have the item type will be removed.Declaration
Swift
open class func shareOptional(_ list: ListBase) -> ComplexValueListParameters
listList whose items will be shared by the resulting list.
Return Value
A new list of item type
ComplexValue?, sharing the same items aslist. -
Throws
EmptyListExceptionif the list has no items,NotUniqueExceptionif the list has multiple items.Declaration
Swift
public final func single() -> ComplexValueReturn Value
A single item from this list.
-
Declaration
Swift
open func skipAndTop(query: DataQuery) -> ComplexValueListParameters
queryData query whose
DataQuery.skipCountandDataQuery.topCountare used for filtering.Return Value
A new list with at most
query.topCountitems of this list, starting at indexquery.skipCount. -
Declaration
Swift
public final func slice(start: Int, end: Int = (2147483647 as Int)) -> ComplexValueListParameters
startZero-based starting index (inclusive), or negative for starting index relative to the end of this list.
endZero-based ending index (exclusive), or negative for ending index relative to the end of this list.
Return Value
A slice of this list from index
start(inclusive) to indexend(exclusive). -
Sort this list in place (stable sort, O(n log n) complexity).
See also
copy,sort.Declaration
Swift
public final func sort(by increasing: @escaping (ComplexValue, ComplexValue) -> Bool)Parameters
increasingPredicate that returns
trueif its first argument should preceed its second argument in the desired ordering. -
Sort this list in-place, using
query.sortItems.Declaration
Swift
open func sortWithQuery(_ query: DataQuery) throwsParameters
queryData query whose whose
DataQuery.sortItemsare used for filtering. -
See also
copy,sort.Declaration
Swift
public final func sorted() -> ComplexValueListReturn Value
a sorted copy of this list using this list’s default
comparerfor ordering (stable sort, O(n log n) complexity). -
See also
copy,sortBy.Declaration
Swift
public final func sorted(by increasing: @escaping (ComplexValue, ComplexValue) -> Bool) -> ComplexValueListParameters
increasingPredicate that returns
trueif its first argument should preceed its second argument in the desired ordering.Return Value
a sorted copy of this list (stable sort, O(n log n) complexity).
-
Declaration
Swift
open func toArray() -> Array<ComplexValue>Return Value
This list converted to a Swift array.
-
Set the item in this list at the specified
index.Declaration
Swift
public final func update(at index: Int, item: ComplexValue)Parameters
indexZero-based index.
itemItem value.
-
Set the item in this list at the specified
index. It is unusual for aComplexValueListto containnilitems, sosetis usually used.Throws
ListIndexExceptionifindexis out of range (0 tolength- 1).Declaration
Swift
open func updateOptional(at index: Int, item: ComplexValue?)Parameters
indexZero-based index.
itemItem value, which might be
nil. -
Override the type of this list, and return this list.
Declaration
Swift
open func withItemType(_ type: DataType) -> ComplexValueListParameters
typeData type for the items in this list.
Return Value
This list.
-
See also
addNullable,getNullable,setNullable.Declaration
Swift
open func withNulls() -> ComplexValueListWithNullsReturn Value
A wrapper of this list using a nullable item type. This may be useful for obtaining an iterator of obviously-nullable items.
-
Override the type of this list, and return this list.
Declaration
Swift
open func withType(_ type: DataType) -> ComplexValueListParameters
typeData type for a list of complex values. Use
DataType.listOfto obtain a suitable list type.Return Value
This list.