StringList

open class StringList: ListBase, Sequence

A list of item type string.

  • Convert array to list.

    Declaration

    Swift

    public static func fromArray(_ array: [String]) -> StringList

    Parameters

    array

    Array with source items.

    Return Value

    New list with items copied from array parameter.

  • Convert list to array.

    Declaration

    Swift

    public func toArray() -> [String]

    Return Value

    New array with items copied from this list.

  • Undocumented

    Declaration

    Swift

    public subscript(index: Int) -> String
  • An immutable empty StringList.

    Declaration

    Swift

    public static let empty: StringList = StringList(capacity: Int(Int32.min))
  • Construct a new list with length of zero and optional initial capacity. A list can expand in length beyond its initial capacity, but best performance will be obtained if the initial capacity is close to the list’s maximum length.

    Declaration

    Swift

    override public init(capacity: Int = (4 as Int))

    Parameters

    capacity

    Optional initial capacity.

  • Add item to the end of this list.

    Declaration

    Swift

    open func append(_ item: String) -> Void

    Parameters

    item

    Item to be added.

  • Add all the items of list to the end of this list.

    Declaration

    Swift

    open func append(contentsOf list: StringList) -> Void

    Parameters

    list

    Items to be added.

  • Concatenate all the string items in this list into a single string value.

    Declaration

    Swift

    open func concat() -> String
  • Declaration

    Swift

    open func copy() -> StringList

    Return Value

    A shallow copy of this list.

  • Declaration

    Swift

    open func dropEmpty() -> StringList

    Return Value

    A new list with the items of this list, excluding empty items.

  • Throws

    EmptyListException if the list is empty.

    Declaration

    Swift

    open func first() -> String

    Return Value

    The first item in this list.

  • Declaration

    Swift

    open func includes(item: String) -> Bool

    Parameters

    item

    Item for comparison. Comparison uses the equality property, which would usually be expected to match the == operator for item type string.

    Return Value

    true if this list contains item.

  • Declaration

    Swift

    open func indexOf(item: String, start: Int = (0 as Int)) -> Int

    Parameters

    item

    Item for comparison. Comparison uses the equality property, which would usually be expected to match the == operator for item type string.

    start

    Zero-based starting index (search moves forwards from this index).

    Return Value

    First index in this list of item, or -1 if not found.

  • Insert item into this list, before the item (if any) at index.

    Throws

    ListIndexException if index is out of range (0 to length).

    Declaration

    Swift

    open func insert(at index: Int, item: String) -> Void

    Parameters

    index

    Zero-based index.

    item

    Item to be added.

  • Insert all items of list into this list, before the item (if any) at index.

    Throws

    ListIndexException if index is out of range (0 to length).

    Declaration

    Swift

    open func insert(at index: Int, contentsOf list: StringList) -> Void

    Parameters

    index

    Zero-based index.

    list

    List of items to be inserted.

  • Throws

    ListIndexException if index is out of range (0 to length - 1).

    Declaration

    Swift

    open func item(at index: Int) -> String

    Parameters

    index

    Zero-based index.

    Return Value

    The item in this list at the specified index.

  • Concatenate all the string items in this list into a single string value, with the specified separator between items.

    Declaration

    Swift

    open func join(separator: String) -> String

    Parameters

    separator

    The separator string value.

  • Declaration

    Swift

    open func joinLines() -> String

    Return Value

    this.join("\n") plus a final newline (if list is non-empty).

  • Throws

    EmptyListException if the list is empty.

    Declaration

    Swift

    open func last() -> String

    Return Value

    The last item in this list.

  • Declaration

    Swift

    open func lastIndexOf(item: String, start: Int = (2147483647 as Int)) -> Int

    Parameters

    item

    Item for comparison. Comparison uses the equality property, which would usually be expected to match the == operator for item type string.

    start

    Zero-based starting index (search moves backwards from this index).

    Return Value

    Last index in this list of item, or -1 if not found.

  • Declaration

    Swift

    open class func lines(_ value: String) -> StringList

    Parameters

    value

    Text where each line is terminated by the newline character (optionally preceeded by carriage return). The final newline character can be omitted.

    Return Value

    A list of the lines in this string.

  • Declaration

    Swift

    open func makeIterator() -> IndexingIterator<Array<String>>

    Return Value

    This list converted to a Swift iterator.

  • Return a new StringList that shares the ListBase.untypedList as the list parameter. To ensure type safety, items in list that do not have the item type string will be removed.

    Declaration

    Swift

    open class func share(_ list: ListBase) -> StringList

    Parameters

    list

    List whose items will be shared by the resulting list.

    Return Value

    A new list of item type string, sharing the same items as list.

  • Throws

    EmptyListException if the list has no items, NotUniqueException if the list has multiple items.

    Declaration

    Swift

    open func single() -> String

    Return Value

    A single item from this list.

  • Declaration

    Swift

    open func slice(start: Int, end: Int = (2147483647 as Int)) -> StringList

    Parameters

    start

    Zero-based starting index (inclusive), or negative for starting index relative to the end of this list.

    end

    Zero-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 index end (exclusive).

  • Sort this list (in place) with a case-insensitive ordering.

    Declaration

    Swift

    open func sortIgnoreCase() -> StringList

    Return Value

    This list.

  • Split a string value into a list of string values, divided by the specified separator.

    Declaration

    Swift

    open class func split(_ value: String, separator: String, limit: Int = (2147483647 as Int)) -> StringList

    Parameters

    value

    The string value to be split.

    separator

    The separator value.

    limit

    separator Maximum number of string values to return. The separator can appear (possibly multiple times) in the final string value.

  • Declaration

    Swift

    open func trimAll() -> StringList

    Return Value

    A new list where each item is the corresponding trimmed item from this list.

  • Set the item in this list at the specified index.

    Declaration

    Swift

    open func update(at index: Int, item: String) -> Void

    Parameters

    index

    Zero-based index.

    item

    Item value.