TreapOfString extension type

A persistent treap implementation using immutable nodes.

Provides efficient insertion, deletion, and lookup operations (O(log N)).

on
Implemented types

Constructors

TreapOfString.of(Iterable<String> items, [Comparator<String>? compare])
Creates a Treap containing the items.

Properties

base TreapBase<String, StringNode>
final
compare Comparator<String>
The Comparator used to determine element order.
finalinherited
first String
The first item in the sorted sequence.
no setterinherited
firstOrDefault String?
The first item in the sorted sequence, or null if this treap is empty.
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
isEmpty bool
Whether this treap is empty.
no setterinherited
last String
The last item in the sorted sequence.
no setterinherited
lastOrDefault String?
The last item in the sorted sequence, or null if this treap is empty.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
size int
The number of items in this treap.
no setterinherited
values Iterable<String>
An Iterable of the items in this treap in ascending order according to compare.
no setterinherited

Methods

add(String item) TreapOfString
Adds an item to this treap.
override
addAll(Iterable<String> items) TreapOfString
Adds all items to this treap.
override
addOrUpdate(String item) TreapOfString
Adds or updates an item in this treap.
override
copy() TreapOfString
Returns a copy of this treap.
override
difference(TreapOfString other) TreapOfString
Returns a new treap containing items from this treap that are not in other.
override
find(String item) String?
Finds the item in this treap equal to item.
inherited
has(String item) bool
Whether this treap contains an item equal to item.
inherited
intersection(TreapOfString other) TreapOfString
Returns a new treap containing only items present in both this treap and other.
override
next(String item) String
Returns the item succeeding item in the sorted sequence.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
prev(String item) String
Returns the item preceding item in the sorted sequence.
inherited
rank(String item) int
Returns the rank of item in the sorted sequence of items.
inherited
remove(String item) TreapOfString
Removes an item from this treap.
override
select(int index) String
Returns the item at the given index in the sorted sequence.
inherited
skip(int count) TreapOfString
Returns a new treap skipping the first n items of the sorted sequence.
override
take(int count) TreapOfString
Returns a new treap containing the first n items of the sorted sequence.
override
toString() String
A string representation of this object.
inherited
union(TreapOfString other) TreapOfString
Returns a new treap containing all items from this treap and other.
override

Operators

operator &(TreapBase<String, StringNode> other) TreapBase<String, StringNode>
Operator overload for the intersection of two treaps.
inherited
operator +(String item) TreapBase<String, StringNode>
Operator overload for adding an item to the treap.
inherited
operator -(TreapBase<String, StringNode> other) TreapBase<String, StringNode>
Operator overload for the difference of two treaps.
inherited
operator ==(Object other) bool
The equality operator.
inherited
operator [](int index) String
Operator overload for selecting an item in the treap by its index.
inherited
operator |(TreapBase<String, StringNode> other) TreapBase<String, StringNode>
Operator overload for the union of two treaps.
inherited