Ejemplo n.º 1
0
        /// <summary>
        /// Tired of Properties not behaving like
        /// <c>Map&lt;String,String&gt;</c>
        /// s?  This method will solve that problem for you.
        /// </summary>
        public static IDictionary <string, string> AsMap(Properties properties)
        {
            IDictionary <string, string> map = Generics.NewHashMap();

            foreach (KeyValuePair <object, object> entry in properties)
            {
                map[(string)entry.Key] = (string)entry.Value;
            }
            return(map);
        }
Ejemplo n.º 2
0
        /// <summary>Compose two maps map1:x-&gt;y and map2:y-&gt;z to get a map x-&gt;z</summary>
        /// <returns>The composed map</returns>
        public static IDictionary <X, Z> Compose <X, Y, Z>(IDictionary <X, Y> map1, IDictionary <Y, Z> map2)
        {
            IDictionary <X, Z> composedMap = Generics.NewHashMap();

            foreach (X key in map1.Keys)
            {
                composedMap[key] = map2[map1[key]];
            }
            return(composedMap);
        }
Ejemplo n.º 3
0
 public FastDisjointSet(ICollection <T> objectSet)
 {
     objectToElement = Generics.NewHashMap();
     foreach (T o in objectSet)
     {
         // create an element
         FastDisjointSet.Element <T> e = new FastDisjointSet.Element <T>(o);
         objectToElement[o] = e;
     }
 }
Ejemplo n.º 4
0
        /// <summary>Inverts a map x-&gt;y to a map y-&gt;pow(x) not assuming unique preimages.</summary>
        /// <returns>The inverted set</returns>
        public static IDictionary <Y, ICollection <X> > InvertSet <X, Y>(IDictionary <X, Y> map)
        {
            IDictionary <Y, ICollection <X> > invertedMap = Generics.NewHashMap();

            foreach (KeyValuePair <X, Y> entry in map)
            {
                X key   = entry.Key;
                Y value = entry.Value;
                PutIntoValueHashSet(invertedMap, value, key);
            }
            return(invertedMap);
        }
Ejemplo n.º 5
0
        /// <summary>Inverts a map x-&gt;y to a map y-&gt;x assuming unique preimages.</summary>
        /// <remarks>Inverts a map x-&gt;y to a map y-&gt;x assuming unique preimages.  If they are not unique, you get an arbitrary ones as the values in the inverted map.</remarks>
        /// <returns>The inverted map</returns>
        public static IDictionary <Y, X> Invert <X, Y>(IDictionary <X, Y> map)
        {
            IDictionary <Y, X> invertedMap = Generics.NewHashMap();

            foreach (KeyValuePair <X, Y> entry in map)
            {
                X key   = entry.Key;
                Y value = entry.Value;
                invertedMap[value] = key;
            }
            return(invertedMap);
        }
 public FourDimensionalMap()
 {
     this.map = Generics.NewHashMap();
 }
Ejemplo n.º 7
0
 /// <summary>Creates a new Index.</summary>
 /// <param name="capacity">Initial capacity of Index.</param>
 public HashIndex(int capacity)
     : base()
 {
     objects = new List <E>(capacity);
     indexes = Generics.NewHashMap(capacity);
 }
Ejemplo n.º 8
0
 /// <summary>Creates a new Index.</summary>
 public HashIndex()
     : base()
 {
     objects = new List <E>();
     indexes = Generics.NewHashMap();
 }
Ejemplo n.º 9
0
 public override IDictionary <K1, V1> SetMap <K1, V1>(IDictionary <K1, V1> map, int initCapacity)
 {
     map = Generics.NewHashMap(initCapacity);
     return(map);
 }
Ejemplo n.º 10
0
 public override IDictionary <K1, V1> SetMap <K1, V1>(IDictionary <K1, V1> map)
 {
     map = Generics.NewHashMap();
     return(map);
 }
Ejemplo n.º 11
0
 public override IDictionary <K, V> NewMap(int initCapacity)
 {
     return(Generics.NewHashMap(initCapacity));
 }
Ejemplo n.º 12
0
 public override IDictionary <K, V> NewMap()
 {
     return(Generics.NewHashMap());
 }
Ejemplo n.º 13
0
 public ArrayHeap(IComparator <E> cmp, int initCapacity)
 {
     this.cmp      = cmp;
     indexToEntry  = new List <ArrayHeap.HeapEntry <E> >(initCapacity);
     objectToEntry = Generics.NewHashMap(initCapacity);
 }
Ejemplo n.º 14
0
 /// <summary>Create an ArrayHeap.</summary>
 /// <param name="cmp">The objects added will be ordered using the <code>Comparator</code>.</param>
 public ArrayHeap(IComparator <E> cmp)
 {
     this.cmp      = cmp;
     indexToEntry  = new List <ArrayHeap.HeapEntry <E> >();
     objectToEntry = Generics.NewHashMap();
 }
 public ThreeDimensionalMap()
 {
     this.map = Generics.NewHashMap();
 }
 public OneToOneMap()
 {
     //------------------------------------------------------------
     m_leftAsKey  = Generics.NewHashMap();
     m_rightAsKey = Generics.NewHashMap();
 }