Ejemplo n.º 1
0
 public void Init()
 {
   list = new ArrayList<int>(TenEqualityComparer.Default);
   guarded = new GuardedList<int>(list);
   seen = new CollectionEventList<int>(IntEqualityComparer.Default);
 }
Ejemplo n.º 2
0
 public void Init()
 {
     list = new ArrayList<int>(TenEqualityComparer.Default);
     guarded = new GuardedList<int>(list);
     seen = new CollectionEventList<int>(System.Collections.Generic.EqualityComparer<int>.Default);
 }
Ejemplo n.º 3
0
 public void Init()
 {
     list    = new ArrayList <int>(TenEqualityComparer.Default);
     guarded = new GuardedList <int>(list);
     seen    = new CollectionEventList <int>(System.Collections.Generic.EqualityComparer <int> .Default);
 }
Ejemplo n.º 4
0
 public void Init()
 {
     list    = new ArrayList <int>(TenEqualityComparer.Default);
     guarded = new GuardedList <int>(list);
     seen    = new CollectionEventList <int>(IntEqualityComparer.Default);
 }
Ejemplo n.º 5
0
 internal ProxyEventBlock(ICollectionValue <T> proxy, ICollectionValue <T> real)
 {
     this.proxy = proxy; this.real = real;
 }
Ejemplo n.º 6
0
 public MappedCollectionValue(ICollectionValue <T> collectionvalue)
 {
     this.collectionvalue = collectionvalue;
 }
Ejemplo n.º 7
0
 public DropMultiplicity(ICollectionValue <KeyValuePair <K, int> > coll) : base(coll)
 {
 }
Ejemplo n.º 8
0
 public MultiplicityOne(ICollectionValue <K> coll) : base(coll)
 {
 }
Ejemplo n.º 9
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="items"></param>
        /// <param name="stringbuilder"></param>
        /// <param name="rest"></param>
        /// <param name="formatProvider"></param>
        /// <returns>True if collection was shown completely</returns>
        public static bool ShowCollectionValue <T>(ICollectionValue <T> items, StringBuilder stringbuilder, ref int rest, IFormatProvider formatProvider)
        {
            string startdelim = "{ ", enddelim = " }";
            bool   showIndexes        = false;
            bool   showMultiplicities = false;
            //TODO: do not test here at run time, but select code at compile time
            //      perhaps by delivering the print type to this metod
            IList <T>       list;
            ICollection <T> coll = items as ICollection <T>;

            if ((list = items as IList <T>) != null)
            {
                startdelim = "[ ";
                enddelim   = " ]";
                //TODO: should have been (items as IIndexed<T>).IndexingSpeed
                showIndexes = list.IndexingSpeed == Speed.Constant;
            }
            else if (coll != null)
            {
                if (coll.AllowsDuplicates)
                {
                    startdelim = "{{ ";
                    enddelim   = " }}";
                    if (coll.DuplicatesByCounting)
                    {
                        showMultiplicities = true;
                    }
                }
            }

            stringbuilder.Append(startdelim);
            rest -= 2 * startdelim.Length;
            bool first    = true;
            bool complete = true;
            int  index    = 0;

            if (showMultiplicities)
            {
                foreach (KeyValuePair <T, int> p in coll.ItemMultiplicities())
                {
                    complete = false;
                    if (rest <= 0)
                    {
                        break;
                    }
                    if (first)
                    {
                        first = false;
                    }
                    else
                    {
                        stringbuilder.Append(", ");
                        rest -= 2;
                    }
                    if (complete = Showing.Show(p.Key, stringbuilder, ref rest, formatProvider))
                    {
                        string multiplicityString = string.Format("(*{0})", p.Value);
                        stringbuilder.Append(multiplicityString);
                        rest -= multiplicityString.Length;
                    }
                }
            }
            else
            {
                foreach (T x in items)
                {
                    complete = false;
                    if (rest <= 0)
                    {
                        break;
                    }
                    if (first)
                    {
                        first = false;
                    }
                    else
                    {
                        stringbuilder.Append(", ");
                        rest -= 2;
                    }
                    if (showIndexes)
                    {
                        string indexString = string.Format("{0}:", index++);
                        stringbuilder.Append(indexString);
                        rest -= indexString.Length;
                    }
                    complete = Showing.Show(x, stringbuilder, ref rest, formatProvider);
                }
            }
            if (!complete)
            {
                stringbuilder.Append("...");
                rest -= 3;
            }
            stringbuilder.Append(enddelim);
            return(complete);
        }