Dict

struct Dict<Value>

A string-keyed dictionary over region-allocated ('heap) nodes. Insertion prepends in O(1), duplicate keys shadow older entries, and lookup is linear.

Properties

let head: DictNode<Value>?

The first node in the linked sequence, when present.

let count: Int

The number of key-value entries.

Methods

mut func insert(consume key: String, consume value: Value) -> Void

Prepends an entry; an existing equal key remains stored but is shadowed.

View Source
pub mut func insert(consume key: String, consume value: Value) -> Void {
	self.head = Optional.some(DictNode(key: key, value: value, next: self.head))
	self.count = self.count + 1
}