Example #1
0
 public Pile <typ> at(int inx)
 {
     if (inx < 0)
     {
         inx = val.Count() + inx + 1;
     }
     Pile <typ> ret = new Pile <typ>(1); ret._name = _name; ret[inx] = this[inx]; return(ret);
 }
Example #2
0
        public Pile <typ> Clone(                                         )
        {
            Pile <typ> ret = new Pile <typ>(Len); ret._name = _name; for (int i = 1; i <= Len; i++)

            {
                ret[i] = this[i];
            }
            return(ret);
        }
Example #3
0
 internal void clear()
 {
     if (strong)
     {
         keyinxS = new Dictionary <kTyp, int>(); inxkeyS = new Dictionary <int, kTyp>();
     }
     else
     {
         keyinxW = new Hashtable(); inxkeyW = new Hashtable();
     } _Keys = null; _kAsc = null; _kDsc = null;
 }
Example #4
0
 public void            Add(kTyp key)
 {
     _Keys = null; _kAsc = null; _kDsc = null; if (strong)
     {
         inxkeyS.Add(keyinxS.Count + 1, key); try { keyinxS.Add(key, keyinxS.Count + 1); } catch (Exception ex) { inxkeyS.Remove(keyinxS.Count + 1); throw ex; }
     }
     else
     {
         inxkeyW.Add(keyinxW.Count + 1, key); try{ keyinxW.Add(key, keyinxW.Count + 1); } catch (Exception ex) { inxkeyW.Remove(keyinxW.Count + 1); throw ex; }
     }
 }
Example #5
0
 public Pile <typ> Add(Pile <typ> more)
 {
     typ[] res = new typ[Len + more.Len]; for (int i = 1; i <= val.Length; i++)
     {
         res[i - 1] = val[i - 1];
     }
     for (int i = 1; i <= more.Len; i++)
     {
         res[i + val.Length - 1] = more[i];
     }
     val = res; return(this);
 }
Example #6
0
        public Pile <typ> after(int inx)
        {
            if (inx < 0)
            {
                inx = val.Count() + inx + 1;
            }
            Pile <typ> ret = new Pile <typ>(1 + val.Count() - inx); ret._name = _name; for (int i = 2; i <= ret.Len; i++)

            {
                ret[i] = this[i + inx - 1];
            }
            return(ret);
        }
Example #7
0
        public Pile <typ> upto(int inx)
        {
            if (inx < 0)
            {
                inx = val.Count() + inx + 1;
            }
            Pile <typ> ret = new Pile <typ>(inx); ret._name = _name; for (int i = 1; i <= ret.Len; i++)

            {
                ret[i] = this[i];
            }
            return(ret);
        }
Example #8
0
        public long                eLabel(int bdy)
        {
            if (lbMap.useReachNotify)
            {
                return(bdy);
            }
            Pile <long> l = lbMap.Labels(bdy, -1); if (l.Len > 0)

            {
                return(l[1]);
            }
            lbMap.AddEnd(bdy, ++eLblMax);   return(eLblMax);
        }
Example #9
0
        public long                sLabel(int bdy)
        {
            if (lbMap.useReachNotify)
            {
                return(bdy);
            }
            Pile <long> l = lbMap.Labels(bdy, 1); if (l.Len > 0)

            {
                return(l[1]);
            }
            lbMap.AddStart(bdy, ++sLblMax); return(sLblMax);
        }
Example #10
0
        private static void   tstSimple()
        {
            long        i    = 0;
            Pile <long> test = new Pile <long>();

            test.Add(1);
            test.Add(2);
            test.Add(3);
            test.Del(2);
            ass(test.Len, 2, "tstSimple.0");
            ass(test[1], 1, "tstSimple.1");
            ass(test[2], 3, "tstSimple.2");
            test.Del(1);
            ass(test[1], 3, "tstSimple.3");
            ass(test.Len, 1, "tstSimple.4");
        }
Example #11
0
        public Pile <typ> slice(int from, int upto)
        {
            if (from < 0)
            {
                from = val.Count() + from + 1;
            }
            if (upto < 0)
            {
                upto = val.Count() + upto + 1;
            }
            Pile <typ> ret = new Pile <typ>(1 + upto - from); ret._name = _name; for (int i = 1; i <= ret.Len; i++)

            {
                ret[i] = this[i + from - 1];
            }
            return(ret);
        }
Example #12
0
 public void            Del(int inx)
 {
     _Keys = null; _kAsc = null; _kDsc = null; if (strong)
     {
         keyinxS.Remove(inxkeyS[inx]); inxkeyS.Remove(inx); for (int i = inx + 1; i <= inxkeyS.Count + 1; i++)
         {
             kTyp key = (kTyp)inxkeyS[i]; inxkeyS.Remove(i); inxkeyS.Add(i - 1, key); keyinxS[key] = i - 1;
         }
     }
     else
     {
         keyinxW.Remove(inxkeyW[inx]); inxkeyW.Remove(inx); for (int i = inx + 1; i <= inxkeyW.Count + 1; i++)
         {
             kTyp key = (kTyp)inxkeyW[i]; inxkeyW.Remove(i); inxkeyW.Add(i - 1, key); keyinxW[key] = i - 1;
         }
     }
 }
Example #13
0
 public KeyInxMap(KeyInxMap <kTyp> cloneFrom)
 {
     init();
     strong = cloneFrom.strong;
     clear();
     if (strong)
     {
         foreach (kTyp key in cloneFrom.keyinxS.Keys)
         {
             keyinxS.Add(key, cloneFrom.keyinxS[key]);
         }
         foreach (int key in cloneFrom.inxkeyS.Keys)
         {
             inxkeyS.Add(key, cloneFrom.inxkeyS[key]);
         }
     }
     else
     {
         foreach (kTyp key in cloneFrom.keyinxW.Keys)
         {
             keyinxW.Add(key, cloneFrom.keyinxW[key]);
         }
         foreach (long key in cloneFrom.inxkeyW.Keys)
         {
             inxkeyW.Add(key, cloneFrom.inxkeyW[key]);
         }
     }
     if (cloneFrom._Keys != null)
     {
         _Keys = cloneFrom._Keys.Clone();
     }
     if (cloneFrom._kAsc != null)
     {
         _kAsc = cloneFrom._kAsc.Clone();
     }
     if (cloneFrom._kDsc != null)
     {
         _kDsc = cloneFrom._kDsc.Clone();
     }
 }
Example #14
0
 public PileEnumerator(Pile <typ> coll)
 {
     Monitor.Enter(coll.val.SyncRoot); this.index = -1; this.coll = coll;
 }
Example #15
0
 public KeyPile(KeyPile <kTyp, iTyp> cloneFrom)
 {
     _name = cloneFrom._name; val = cloneFrom.val.Clone(); kim = new KeyInxMap <kTyp>(cloneFrom.kim);
 }
Example #16
0
 public KeyPile(                               )
 {
     this.uniqueKeys = true; this.val = new Pile <iTyp>(); this.kim = new KeyInxMap <kTyp>(uniqueKeys);
 }