Adds a key/value pair to the
IDictionary if the key does not already exist.
Syntax
Parameters
- key
- The key of the element to add.
- fnCreate
- Constructs a new value for the key.
Exceptions
Example
BPlusTree/BPlusTree.Test/BasicTests.cs
C# | Copy Code |
---|
using (BPlusTree<int, string> data = Create(Options))
{
Assert.AreEqual("a", data.GetOrAdd(1, "a"));
Assert.AreEqual("a", data.GetOrAdd(1, "b"));
Assert.AreEqual("b", data.GetOrAdd(2, k => "b"));
Assert.AreEqual("b", data.GetOrAdd(2, k => "c"));
} |
VB.NET | Copy Code |
---|
Using data As BPlusTree(Of Integer, String) = Create(Options)
Assert.AreEqual("a", data.GetOrAdd(1, "a"))
Assert.AreEqual("a", data.GetOrAdd(1, "b"))
Assert.AreEqual("b", data.GetOrAdd(2, Function(k) "b"))
Assert.AreEqual("b", data.GetOrAdd(2, Function(k) "c"))
End Using |
Requirements
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
See Also