Table of Contents

Class BsonTrie<TValue>

Namespace
MongoDB.Bson.IO
Assembly
MongoDB.Bson.dll

Represents a mapping from a set of UTF8 encoded strings to a set of elementName/value pairs, implemented as a trie.

public class BsonTrie<TValue>

Type Parameters

TValue

The type of the BsonTrie values.

Inheritance
BsonTrie<TValue>
Inherited Members
Extension Methods

Constructors

BsonTrie()

Initializes a new instance of the BsonTrie class.

public BsonTrie()

Properties

Root

Gets the root node.

public BsonTrieNode<TValue> Root { get; }

Property Value

BsonTrieNode<TValue>

Methods

Add(string, TValue)

Adds the specified elementName (after encoding as a UTF8 byte sequence) and value to the trie.

public void Add(string elementName, TValue value)

Parameters

elementName string

The element name to add.

value TValue

The value to add. The value can be null for reference types.

TryGetNode(BsonStream, out BsonTrieNode<TValue>)

Tries to get the node associated with a name read from a stream.

public bool TryGetNode(BsonStream stream, out BsonTrieNode<TValue> node)

Parameters

stream BsonStream

The stream.

node BsonTrieNode<TValue>

The node.

Returns

bool

True if the node was found. If the node was found the stream is advanced over the name, otherwise the stream is repositioned to the beginning of the name.

TryGetNode(ArraySegment<byte>, out BsonTrieNode<TValue>)

Gets the node associated with the specified element name.

public bool TryGetNode(ArraySegment<byte> utf8, out BsonTrieNode<TValue> node)

Parameters

utf8 ArraySegment<byte>

The element name.

node BsonTrieNode<TValue>

When this method returns, contains the node associated with the specified element name, if the key is found; otherwise, null. This parameter is passed uninitialized.

Returns

bool

True if the node was found; otherwise, false.

TryGetValue(ArraySegment<byte>, out TValue)

Gets the value associated with the specified element name.

public bool TryGetValue(ArraySegment<byte> utf8, out TValue value)

Parameters

utf8 ArraySegment<byte>

The element name.

value TValue

When this method returns, contains the value associated with the specified element name, if the key is found; otherwise, the default value for the type of the value parameter. This parameter is passed uninitialized.

Returns

bool

True if the value was found; otherwise, false.

TryGetValue(string, out TValue)

Gets the value associated with the specified element name.

public bool TryGetValue(string elementName, out TValue value)

Parameters

elementName string

The element name.

value TValue

When this method returns, contains the value associated with the specified element name, if the key is found; otherwise, the default value for the type of the value parameter. This parameter is passed uninitialized.

Returns

bool

True if the value was found; otherwise, false.