示例#1
0
        /// <summary>
        /// Upserts the value associated with the specified [key0 key1.... keyN].
        /// </summary>
        /// <param name="replaceExistingData">Specify if the existing val should be overwritten if the [key0 key1.... keyN value] already exists.</param>
        /// <param name="a">Key0 of type A, of [key0 key1.... keyN value] pair.</param>
        /// <param name="b">Key1 of type B, of [key0 key1.... keyN value] pair.</param>
        /// <param name="val">Value of [key0 key1.... keyN value] pair.</param>
        public void Upsert(bool replaceExistingData, A a, B b, VALUE val)
        {
            int level = 0;
            NKeyHash <B, VALUE> bsA1l = null;

            if (this.Values.TryGetValue(a, out bsA1l))
            {
                if (bsA1l.ContainsKey(b))
                {
                    if (replaceExistingData)
                    {
                        bsA1l[b] = val;
                    }
                    return;
                }
                else
                {
                    level = 2;
                }
            }
            else
            {
                level = 1;
            }

            if (level == 1)
            {
                bsA1l = new  NKeyHash <B, VALUE>(this.UnderlyingHashType); this.Values.Add(a, bsA1l); level++;
            }
            if (level == 2)
            {
                bsA1l.Add(b, val);
            }
        }
示例#2
0
        /// <summary>
        /// Upserts the value associated with the specified [key0 key1.... keyN].
        /// </summary>
        /// <param name="replaceExistingData">Specify if the existing val should be overwritten if the [key0 key1.... keyN value] already exists.</param>
        /// <param name="a">Key0 of type A, of [key0 key1.... keyN value] pair.</param>
        /// <param name="b">Key1 of type B, of [key0 key1.... keyN value] pair.</param>
        /// <param name="c">Key2 of type C, of [key0 key1.... keyN value] pair.</param>
        /// <param name="d">Key3 of type D, of [key0 key1.... keyN value] pair.</param>
        /// <param name="val">Value of [key0 key1.... keyN value] pair.</param>
        public void Upsert(bool replaceExistingData, A a, B b, C c, D d, VALUE val)
        {
            int level = 0;
            NKeyHash <B, NKeyHash <C, NKeyHash <D, VALUE> > > bsA1l = null;
            NKeyHash <C, NKeyHash <D, VALUE> > csA1l = null;
            NKeyHash <D, VALUE> dsA1l = null;

            if (this.Values.TryGetValue(a, out bsA1l))
            {
                if (bsA1l.TryGetValue(b, out csA1l))
                {
                    if (csA1l.TryGetValue(c, out dsA1l))
                    {
                        if (dsA1l.ContainsKey(d))
                        {
                            if (replaceExistingData)
                            {
                                dsA1l[d] = val;
                            }
                            return;
                        }
                        else
                        {
                            level = 4;
                        }
                    }
                    else
                    {
                        level = 3;
                    }
                }
                else
                {
                    level = 2;
                }
            }
            else
            {
                level = 1;
            }

            if (level == 1)
            {
                bsA1l = new  NKeyHash <B, NKeyHash <C, NKeyHash <D, VALUE> > >(this.UnderlyingHashType); this.Values.Add(a, bsA1l); level++;
            }
            if (level == 2)
            {
                csA1l = new  NKeyHash <C, NKeyHash <D, VALUE> >(this.UnderlyingHashType); bsA1l.Add(b, csA1l); level++;
            }
            if (level == 3)
            {
                dsA1l = new  NKeyHash <D, VALUE>(this.UnderlyingHashType); csA1l.Add(c, dsA1l); level++;
            }
            if (level == 4)
            {
                dsA1l.Add(d, val);
            }
        }
        /// <summary>
        /// Returns a copy of the underlying base NKeyHash object.  It could possibly be a reference copy depending on the underlying key and value objects. If you wish to create a value-copy of the NKeyHash object, then you'll have to write one.
        /// </summary>
        /// <returns></returns>
        public NKeyHash <A, VALUE> Copy()
        {
            NKeyHash <A, VALUE> cpy = new NKeyHash <A, VALUE>(this.UnderlyingHashType);

            foreach (var kvp in this)
            {
                cpy.Upsert(true, kvp.Key, kvp.Value);
            }
            return(cpy);
        }
示例#4
0
 /// <summary>
 /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 /// </summary>
 public void Dispose()
 {
     this.Values = null;
 }
示例#5
0
        /// <summary>
        /// Upserts the value associated with the specified [key0 key1.... keyN].
        /// </summary>
        /// <param name="replaceExistingData">Specify if the existing val should be overwritten if the [key0 key1.... keyN value] already exists.</param>
        /// <param name="a">Key0 of type A, of [key0 key1.... keyN value] pair.</param>
        /// <param name="b">Key1 of type B, of [key0 key1.... keyN value] pair.</param>
        /// <param name="c">Key2 of type C, of [key0 key1.... keyN value] pair.</param>
        /// <param name="d">Key3 of type D, of [key0 key1.... keyN value] pair.</param>
        /// <param name="e">Key4 of type E, of [key0 key1.... keyN value] pair.</param>
        /// <param name="f">Key5 of type F, of [key0 key1.... keyN value] pair.</param>
        /// <param name="g">Key6 of type G, of [key0 key1.... keyN value] pair.</param>
        /// <param name="h">Key7 of type H, of [key0 key1.... keyN value] pair.</param>
        /// <param name="val">Value of [key0 key1.... keyN value] pair.</param>
        public void Upsert(bool replaceExistingData, A a, B b, C c, D d, E e, F f, G g, H h, VALUE val)
        {
            int level = 0;
            NKeyHash <B, NKeyHash <C, NKeyHash <D, NKeyHash <E, NKeyHash <F, NKeyHash <G, NKeyHash <H, VALUE> > > > > > > bsA1l = null;
            NKeyHash <C, NKeyHash <D, NKeyHash <E, NKeyHash <F, NKeyHash <G, NKeyHash <H, VALUE> > > > > > csA1l = null;
            NKeyHash <D, NKeyHash <E, NKeyHash <F, NKeyHash <G, NKeyHash <H, VALUE> > > > > dsA1l = null;
            NKeyHash <E, NKeyHash <F, NKeyHash <G, NKeyHash <H, VALUE> > > > esA1l = null;
            NKeyHash <F, NKeyHash <G, NKeyHash <H, VALUE> > > fsA1l = null;
            NKeyHash <G, NKeyHash <H, VALUE> > gsA1l = null;
            NKeyHash <H, VALUE> hsA1l = null;

            if (this.Values.TryGetValue(a, out bsA1l))
            {
                if (bsA1l.TryGetValue(b, out csA1l))
                {
                    if (csA1l.TryGetValue(c, out dsA1l))
                    {
                        if (dsA1l.TryGetValue(d, out esA1l))
                        {
                            if (esA1l.TryGetValue(e, out fsA1l))
                            {
                                if (fsA1l.TryGetValue(f, out gsA1l))
                                {
                                    if (gsA1l.TryGetValue(g, out hsA1l))
                                    {
                                        if (hsA1l.ContainsKey(h))
                                        {
                                            if (replaceExistingData)
                                            {
                                                hsA1l[h] = val;
                                            }
                                            return;
                                        }
                                        else
                                        {
                                            level = 8;
                                        }
                                    }
                                    else
                                    {
                                        level = 7;
                                    }
                                }
                                else
                                {
                                    level = 6;
                                }
                            }
                            else
                            {
                                level = 5;
                            }
                        }
                        else
                        {
                            level = 4;
                        }
                    }
                    else
                    {
                        level = 3;
                    }
                }
                else
                {
                    level = 2;
                }
            }
            else
            {
                level = 1;
            }

            if (level == 1)
            {
                bsA1l = new  NKeyHash <B, NKeyHash <C, NKeyHash <D, NKeyHash <E, NKeyHash <F, NKeyHash <G, NKeyHash <H, VALUE> > > > > > >(this.UnderlyingHashType); this.Values.Add(a, bsA1l); level++;
            }
            if (level == 2)
            {
                csA1l = new  NKeyHash <C, NKeyHash <D, NKeyHash <E, NKeyHash <F, NKeyHash <G, NKeyHash <H, VALUE> > > > > >(this.UnderlyingHashType); bsA1l.Add(b, csA1l); level++;
            }
            if (level == 3)
            {
                dsA1l = new  NKeyHash <D, NKeyHash <E, NKeyHash <F, NKeyHash <G, NKeyHash <H, VALUE> > > > >(this.UnderlyingHashType); csA1l.Add(c, dsA1l); level++;
            }
            if (level == 4)
            {
                esA1l = new  NKeyHash <E, NKeyHash <F, NKeyHash <G, NKeyHash <H, VALUE> > > >(this.UnderlyingHashType); dsA1l.Add(d, esA1l); level++;
            }
            if (level == 5)
            {
                fsA1l = new  NKeyHash <F, NKeyHash <G, NKeyHash <H, VALUE> > >(this.UnderlyingHashType); esA1l.Add(e, fsA1l); level++;
            }
            if (level == 6)
            {
                gsA1l = new  NKeyHash <G, NKeyHash <H, VALUE> >(this.UnderlyingHashType); fsA1l.Add(f, gsA1l); level++;
            }
            if (level == 7)
            {
                hsA1l = new  NKeyHash <H, VALUE>(this.UnderlyingHashType); gsA1l.Add(g, hsA1l); level++;
            }
            if (level == 8)
            {
                hsA1l.Add(h, val);
            }
        }
示例#6
0
 /// <summary>
 /// Removes all keys and values.
 /// </summary>
 public void Clear()
 {
     this.Values = new NKeyHash <A, NKeyHash <B, NKeyHash <C, NKeyHash <D, NKeyHash <E, NKeyHash <F, NKeyHash <G, NKeyHash <H, VALUE> > > > > > > >(this.UnderlyingHashType);
 }
示例#7
0
 /// <summary>
 /// Removes all keys and values.
 /// </summary>
 public void Clear()
 {
     this.Values = new NKeyHash <A, NKeyHash <B, VALUE> >(this.UnderlyingHashType);
 }