C# Класс clojure.lang.PersistentTreeMap

Implements a persistent Red-Black Tree.

>Note that instances of this class are constant values i.e., add/remove etc return new values.See Okasaki, Kahrs, Larsen et al

Наследование: APersistentMap, Reversible, Sorted
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
EMPTY PersistentTreeMap

Защищенные свойства (Protected)

Свойство Тип Описание
_comp IComparer
_count int

Открытые методы

Метод Описание
DoCompare ( object k1, object k2 ) : int

Compare two keys.

GetEnumerator ( ) : IDictionaryEnumerator
PersistentTreeMap ( ) : System

Initialize a PersistentTreeMap using a default comparer.

PersistentTreeMap ( IPersistentMap meta, IComparer comp ) : System

Initialize a PersistentTreeMap using given metadata and comparer.

assoc ( object key, object val ) : IPersistentMap

Add a new key/value pair.

Overwrites an exising value for the key, if present.

assocEx ( object key, object val ) : IPersistentMap

Add a new key/value pair.

Throws an exception if key has a value already.

comparator ( ) : System.Collections.IComparer

Returns the comparer used to sort the elements in the collection.

Would be called Comparer except we need to match the JVM name.

containsKey ( object key ) : bool

Test if the map contains a key.

count ( ) : int

Gets the number of items in the collection.

create ( IDictionary other ) : IPersistentMap

Create a PersistentTreeMap from a dictionary.

create ( IComparer comp, ISeq items ) : PersistentTreeMap

Create a PersistentTreeMap from a comparison method an ISeq of alternating keys and values.

create ( ISeq items ) : PersistentTreeMap

Create a PersistentTreeMap from an ISeq of alternating keys and values.

empty ( ) : IPersistentCollection

Gets an empty collection of the same type.

entryAt ( object key ) : IMapEntry

Returns the key/value pair for this key.

entryKey ( object entry ) : object

Returns the key to be passed to the comparator to sort the element.

rseq ( ) : ISeq

Gets an ISeq to travers the sequence in reverse.

seq ( ) : ISeq

Gets an ISeq to allow first/rest iteration through the collection.

seq ( bool ascending ) : ISeq

Returns an ISeq to iterate through the collection in the designated direction.

seqFrom ( object key, bool ascending ) : ISeq

Returns an ISeq to iterate through the collection in the designated direction starting from a particular key.

The key need not be in the collection. If not present, the iteration will start with the first element with a key greater than (if asscending) or less than (if descending) the given key.

valAt ( object key ) : object

Gets the value associated with a key.

valAt ( object key, object notFound ) : object

Gets the value associated with a key.

withMeta ( IPersistentMap meta ) : IObj

Create a copy with new metadata.

without ( object key ) : IPersistentMap

Remove a key entry.

Приватные методы

Метод Описание
Add ( Node t, object key, object val, clojure.lang.Box found ) : Node

Add a node for a key

Append ( Node left, Node right ) : Node
BalanceLeftDel ( object key, object val, Node del, Node right ) : Node
BalanceRightDel ( object key, object val, Node left, Node del ) : Node
LeftBalance ( object key, object val, Node ins, Node right ) : Node
MakeBlack ( object key, object val, Node left, Node right ) : Black
MakeRed ( object key, object val, Node left, Node right ) : Red
NodeAt ( object key ) : Node

Get the Node containing a key, or null if key not in tree.

PersistentTreeMap ( IComparer comp ) : System

Initialize a PersistentTreeMap using a given comparer.

PersistentTreeMap ( IComparer comp, Node tree, int count, IPersistentMap meta ) : System

Initialize a PersistentTreeMap using given internal data. (Internal use only.)

PersistentTreeMap ( IPersistentMap meta, IComparer comp, Node tree, int count ) : System
Remove ( Node t, object key, clojure.lang.Box found ) : Node
Replace ( Node t, object key, object val ) : Node
RightBalance ( object key, object val, Node left, Node ins ) : Node

Описание методов

DoCompare() публичный Метод

Compare two keys.
public DoCompare ( object k1, object k2 ) : int
k1 object The first key.
k2 object The second key.
Результат int

GetEnumerator() публичный Метод

public GetEnumerator ( ) : IDictionaryEnumerator
Результат IDictionaryEnumerator

PersistentTreeMap() публичный Метод

Initialize a PersistentTreeMap using a default comparer.
public PersistentTreeMap ( ) : System
Результат System

PersistentTreeMap() публичный Метод

Initialize a PersistentTreeMap using given metadata and comparer.
public PersistentTreeMap ( IPersistentMap meta, IComparer comp ) : System
meta IPersistentMap
comp IComparer
Результат System

assoc() публичный Метод

Add a new key/value pair.
Overwrites an exising value for the key, if present.
public assoc ( object key, object val ) : IPersistentMap
key object The key
val object The value
Результат IPersistentMap

assocEx() публичный Метод

Add a new key/value pair.
Throws an exception if key has a value already.
public assocEx ( object key, object val ) : IPersistentMap
key object The key
val object The value
Результат IPersistentMap

comparator() публичный Метод

Returns the comparer used to sort the elements in the collection.
Would be called Comparer except we need to match the JVM name.
public comparator ( ) : System.Collections.IComparer
Результат System.Collections.IComparer

containsKey() публичный Метод

Test if the map contains a key.
public containsKey ( object key ) : bool
key object The key to test for membership
Результат bool

count() публичный Метод

Gets the number of items in the collection.
public count ( ) : int
Результат int

create() публичный статический Метод

Create a PersistentTreeMap from a dictionary.
public static create ( IDictionary other ) : IPersistentMap
other IDictionary The dictionary to initialize from.
Результат IPersistentMap

create() публичный статический Метод

Create a PersistentTreeMap from a comparison method an ISeq of alternating keys and values.
public static create ( IComparer comp, ISeq items ) : PersistentTreeMap
comp IComparer A comparison method.
items ISeq The ISeq of alternating keys and values.
Результат PersistentTreeMap

create() публичный статический Метод

Create a PersistentTreeMap from an ISeq of alternating keys and values.
public static create ( ISeq items ) : PersistentTreeMap
items ISeq The ISeq of alternating keys and values.
Результат PersistentTreeMap

empty() публичный Метод

Gets an empty collection of the same type.
public empty ( ) : IPersistentCollection
Результат IPersistentCollection

entryAt() публичный Метод

Returns the key/value pair for this key.
public entryAt ( object key ) : IMapEntry
key object The key to retrieve
Результат IMapEntry

entryKey() публичный Метод

Returns the key to be passed to the comparator to sort the element.
public entryKey ( object entry ) : object
entry object An element in the collection.
Результат object

rseq() публичный Метод

Gets an ISeq to travers the sequence in reverse.
public rseq ( ) : ISeq
Результат ISeq

seq() публичный Метод

Gets an ISeq to allow first/rest iteration through the collection.
public seq ( ) : ISeq
Результат ISeq

seq() публичный Метод

Returns an ISeq to iterate through the collection in the designated direction.
public seq ( bool ascending ) : ISeq
ascending bool A flag indicating if the iteration is ascending or descending.
Результат ISeq

seqFrom() публичный Метод

Returns an ISeq to iterate through the collection in the designated direction starting from a particular key.
The key need not be in the collection. If not present, the iteration will start with the first element with a key greater than (if asscending) or less than (if descending) the given key.
public seqFrom ( object key, bool ascending ) : ISeq
key object The key at which to start the iteration.
ascending bool A flag indicating if the iteration is ascending or descending.
Результат ISeq

valAt() публичный Метод

Gets the value associated with a key.
public valAt ( object key ) : object
key object The key to look up.
Результат object

valAt() публичный Метод

Gets the value associated with a key.
public valAt ( object key, object notFound ) : object
key object The key to look up.
notFound object The value to return if the key is not present.
Результат object

withMeta() публичный Метод

Create a copy with new metadata.
public withMeta ( IPersistentMap meta ) : IObj
meta IPersistentMap The new metadata.
Результат IObj

without() публичный Метод

Remove a key entry.
public without ( object key ) : IPersistentMap
key object The key to remove
Результат IPersistentMap

Описание свойств

EMPTY публичное статическое свойство

An empty PersistentTreeMap.
public static PersistentTreeMap,clojure.lang EMPTY
Результат PersistentTreeMap

_comp защищенное свойство

The method used to compare elements for sorting.
protected IComparer _comp
Результат IComparer

_count защищенное свойство

Number of items in the tree.
protected int _count
Результат int