Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

A Concurrent Collection: a MultiMap Generic Collection Class in C# - Part 2

, 5 Jun 2009
MultiMap is similar to a .NET Dictionary collection type, but accepts duplicate Key,Value pairs during addition. The MultiMap collection is also a concurrent collection.
ConsoleTest.zip
ConsoleTest
bin
Release
ConsoleTest.exe
MultiMap.dll
Properties
MultiMap
bin
Release
MultiMap.dll
MultiMap.suo
Properties
MultiMapTest
bin
Release
MultiMap.dll
MultiMapTest.exe
Properties
Settings.settings
Demo.zip
Demo
MultiMap.dll
MultiMapTest.exe
MultiMap.zip
MultiMapTest.zip
Debug
MultiMap.dll
MultiMap.pdb
MultiMapTest.exe
MultiMapTest.pdb
MultiMapTest.vshost.exe
MultiMap.dll
MultiMap.pdb
MultiMapTest.exe
MultiMapTest.pdb
MultiMapTest.vshost.exe
MultiMapTest.vshost.exe.manifest
obj
Debug
MultiMapTest.csproj.GenerateResource.Cache
MultiMapTest.exe
MultiMapTest.Form1.resources
MultiMapTest.pdb
MultiMapTest.Properties.Resources.resources
TempPE
Release
MultiMapTest.csproj.GenerateResource.Cache
MultiMapTest.exe
MultiMapTest.Form1.resources
MultiMapTest.pdb
MultiMapTest.Properties.Resources.resources
TempPE
Settings.settings
Debug
ConsoleTest.exe
ConsoleTest.pdb
ConsoleTest.vshost.exe
MultiMap.dll
MultiMap.pdb
ConsoleTest.exe
ConsoleTest.pdb
ConsoleTest.vshost.exe
ConsoleTest.vshost.exe.manifest
MultiMap.dll
MultiMap.pdb
obj
Debug
ConsoleTest.exe
ConsoleTest.pdb
TempPE
Release
ConsoleTest.exe
ConsoleTest.pdb
ResolveAssemblyReference.cache
TempPE
Debug
MultiMap.dll
MultiMap.pdb
MultiMap.dll
MultiMap.pdb
obj
Debug
MultiMap.dll
MultiMap.pdb
TempPE
Release
MultiMap.dll
MultiMap.pdb
TempPE
using System;
using BK.Util;

namespace ConsoleTest
{
    class Program
    {
        static void Main(string[] args)
        {
            ///////////////////////////////////////////////////////////////
            /// Creation and Initialization of the Collection class     ///
            ///////////////////////////////////////////////////////////////
            MultimapBK<string, string> multiMapCollection = new MultimapBK<string, string>();

            multiMapCollection.Add("Alice", "Home: 333-222-9999");
            multiMapCollection.Add("Alice", "Office: 222-211-9999");
            multiMapCollection.Add("Bob", "Home: 111-112-9999");
            multiMapCollection.Add("Bob", "Office: 121-112-9999");
            multiMapCollection.Add("Bob", "Office: 122-112-9999");

            // Search for Key - Bob
            string SearchKey = "Alice";

            // Get the First Item
            string ValueRet = multiMapCollection.GetFirstItem(SearchKey);

            while (ValueRet != null)
            {
                string SearchKey1 = "Bob";
                // Print the Item to console.
                System.Console.WriteLine("Key = {0}; Value = {1}", SearchKey1, ValueRet);
                // Get next Item
                ValueRet = multiMapCollection.GetNextItem(SearchKey1);
            }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Bharath K A
Software Developer (Senior)
United States United States
No Biography provided

| Advertise | Privacy | Mobile
Web02 | 2.8.140827.1 | Last Updated 5 Jun 2009
Article Copyright 2009 by Bharath K A
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid