Struct

struct EntryView<K, V> where K <: Hashable & Equatable<K>

public struct EntryView<K, V>  where K <: Hashable & Equatable<K>

Description: Specifies the view of a Key in HashMap.

By modifying the view, you can quickly obtain or modify the value of Value corresponding to Key in HashMap. In the process of using the view, if some elements are modified, added, or deleted in a collection, the view becomes invalid and ConcurrentModificationException is thrown.

The instance of this struct can be obtained only by using the func entryView(K) method of the corresponding HashMap instance.

func getKey()

public func getKey(): K

Description: Obtains the key in a view. The time complexity is O(1).

Returns:

  • K: key of the view

Throws:

func getValue()

public func getValue(): ?V

Description: Obtains the value in a view. The time complexity is O(1).

If the view is empty, None is returned. Otherwise, the value of the key is returned.

Returns:

  • ?V: value of the view

Throws:

func isAbsent()

public func isAbsent(): Bool

Description: Checks whether a view is empty.

If the view is empty, the corresponding HashMap instance does not contain the (Key, Value) combination whose Key value is the same as the Key value of the view.

Returns:

  • Bool: If the view is empty, true is returned. Otherwise, false is returned.

func setValue(V)

public mut func setValue(v: V): V

Description: Sets the value in a view. The time complexity is O(1).

If the view is empty, a specified key-value pair is inserted and the inserted value is returned. Otherwise, the value before the setting is returned.

Parameters:

  • v: V: specified value

Returns:

  • V: value of the view or newly inserted value

Throws:

struct TreeMapNode<K, V> where K <: Comparable<K>

public struct TreeMapNode<K, V> where K <: Comparable<K>

Description: Specifies the node structure of TreeMap.

Note:

When a TreeMapNode instance is used to perform node operations, if an insertion or a deletion operation is performed on the corresponding TreeMap instance, the TreeMapNode instance becomes invalid. If the invalid TreeMapNode instance is operated, a ConcurrentModificationException exception is thrown.

prop key

public prop key: K

Description: Obtains the key of the current node.

Type: K

Throws:

prop value

public mut prop value: V

Description: Obtains or sets the value of the current node.

Type: V

Throws:

func backward(K, Bool)

public func backward(bound: K, inclusive!:Bool = true): Iterator<(K, V)>

Description: Generates a positive-order iterator from the current node to bound.

Parameters:

  • bound: K: passed key
  • inclusive!: Bool: whether to contain the passed key; default value: true (yes)

Returns:

  • Iterator <(K, V) >: positive-order iterator from the current node to bound

Throws:

func forward(K, Bool)

public func forward(bound: K, inclusive!:Bool = true): Iterator<(K, V)>

Description: Generates a reverse-order iterator from the current node to bound.

Parameters:

  • bound: K: passed key
  • inclusive!: Bool: whether to contain the passed key; default value: true (yes)

Returns:

  • Iterator <(K, V) >: reverse-order iterator from the current node to bound

Throws:

func next()

public func next(): Option<TreeMapNode<K, V>>

Description: Access the successor nodes.

Returns:

Throws:

func prev()

public func prev(): Option<TreeMapNode<K, V>>

Description: Access the predecessor nodes.

Returns:

Throws: