CSharpTest.Net
LurchTable<TKey,TValue> Constructor(LurchTableOrder,Int32,Int32,Int32,Int32,IEqualityComparer<TKey>)
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class > LurchTable<TKey,TValue> Constructor : LurchTable<TKey,TValue> Constructor(LurchTableOrder,Int32,Int32,Int32,Int32,IEqualityComparer<TKey>)

ordering
The type of linking for the items
limit
The maximum allowable number of items, or int.MaxValue for unlimited
hashSize
The number of hash buckets to use for the collection, usually 1/2 estimated capacity
allocSize
The number of entries to allocate at a time, usually 1/16 estimated capacity
lockSize
The number of concurrency locks to preallocate, usually 1/256 estimated capacity
comparer
The element hash generator for keys

Glossary Item Box

Creates a LurchTable that orders items by (ordering) and removes items once the specified (limit) is reached.

Syntax

Visual Basic (Declaration) 
Public Function New( _
   ByVal ordering As LurchTableOrder, _
   ByVal limit As Integer, _
   ByVal hashSize As Integer, _
   ByVal allocSize As Integer, _
   ByVal lockSize As Integer, _
   ByVal comparer As IEqualityComparer(Of TKey) _
)
C# 
public LurchTable<TKey,TValue>( 
   LurchTableOrder ordering,
   int limit,
   int hashSize,
   int allocSize,
   int lockSize,
   IEqualityComparer<TKey> comparer
)

Parameters

ordering
The type of linking for the items
limit
The maximum allowable number of items, or int.MaxValue for unlimited
hashSize
The number of hash buckets to use for the collection, usually 1/2 estimated capacity
allocSize
The number of entries to allocate at a time, usually 1/16 estimated capacity
lockSize
The number of concurrency locks to preallocate, usually 1/256 estimated capacity
comparer
The element hash generator for keys

Example

Library/Library.Test/TestLurchTable.cs

C#Copy Code
//multiple of prime will produce hash collision, thus testing removal of non-first elements
const int prime = 1103;
var test = new LurchTable<int, string>(LurchTableOrder.Access, 10, prime, 10, 10, EqualityComparer<int>.Default);
test[1 * prime] = "a";
test[2 * prime] = "b";
test[3 * prime] = "c";
test[4 * prime] = "d";
test[5 * prime] = "e";
Assert.IsTrue(test.Remove(4 * prime));
Assert.IsTrue(test.Remove(2 * prime));
Assert.IsTrue(test.Remove(5 * prime));
Assert.IsTrue(test.Remove(1 * prime));
Assert.IsTrue(test.Remove(3 * prime));
Assert.AreEqual(0, test.Count);
VB.NETCopy Code
'multiple of prime will produce hash collision, thus testing removal of non-first elements
Const  prime As Integer = 1103
Dim test As var = New LurchTable(Of Integer, String)(LurchTableOrder.Access, 10, prime, 10, 10, EqualityComparer(Of Integer).[Default])
test(1 * prime) = "a"
test(2 * prime) = "b"
test(3 * prime) = "c"
test(4 * prime) = "d"
test(5 * prime) = "e"
Assert.IsTrue(test.Remove(4 * prime))
Assert.IsTrue(test.Remove(2 * prime))
Assert.IsTrue(test.Remove(5 * prime))
Assert.IsTrue(test.Remove(1 * prime))
Assert.IsTrue(test.Remove(3 * prime))
Assert.AreEqual(0, test.Count)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys