HashSet - HashSet implemetation which is missing in .NET CF

Click here for project page


License

Apache License 2.0

Summary

An implementation of HashSet class in .NET that can be used in .NET Compact Framework (.NET CF), in which it is natively missing

Key Features

Usage

Examples of basic usage of a HashSet(Of String):

  1. Initialize a HashSet(Of String):

    Dim strHs = New HashSet(Of String)
    Assert.AreEqual(strHs.Count, 0)
    
  2. Add an element:

    Dim strHs = New HashSet(Of String)
    strHs.Add("first")
    Assert.IsTrue(strHs.Contains("first"))
    
  3. Remove an element:

    Dim strHs = New HashSet(Of String)
    strHs.Add("first")
    strHs.Remove("first")
    Assert.IsFalse(strHs.Contains("first"))
    
  4. Clear elements:

    Dim strHs = New HashSet(Of String)
    strHs.Add("first")
    strHs.Add("second")
    strHs.Add("third")
    Assert.AreEqual(strHs.Count, 3)
    strHs.Clear()
    Assert.AreEqual(strHs.Count, 0)
    
  5. Compare HashSets

    Dim strHs1 = New HashSet(Of String)
    strHs1.Add("first")
    strHs1.Add("second")
    strHs1.Add("third")
    Dim strHs2 = New HashSet(Of String)(strHs1)
    Assert.IsTrue(strHs1 = strHs2)
    strHs2.Remove("second")
    Assert.IsTrue(strHs1 <> strHs2)
    

How to Build

This library and associated unit tests were developed in VS 2008 as Smart Device projects.

Releases


Author:  Albert Ho <albertho -at- kdsecure.com>
Copyright: (c) 2010 by KD Secure, LLC
NO WARRANTY, EXPRESS OR IMPLIED.  USE AT-YOUR-OWN-RISK.