Exemplo n.º 1
0
        /// <summary>
        /// String representation of a sequence
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder("Sequence(");

            if (this.count > 0)
            {
                //^ assume head != null;
                DoubleLinkedNode cur = head;
                int  i       = 0;
                bool isFirst = true;
                while (i < this.count)
                {
                    if (!isFirst)
                    {
                        sb.Append(", ");
                    }
                    PrettyPrinter.Format(sb, cur.elem);
                    isFirst = false;
                    cur     = cur.next;
                    i      += 1;
                }
            }
            sb.Append(")");
            return(sb.ToString());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Formats this triple as "Triple&lt;T1,T2&gt;(first, second)"
        /// </summary>
        /// <returns>The formatted string</returns>
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder("Pair(");

            PrettyPrinter.Format(sb, this.first);
            sb.Append(", ");
            PrettyPrinter.Format(sb, this.second);
            sb.Append(")");
            return(sb.ToString());
        }
Exemplo n.º 3
0
        /// <summary>
        /// String representation of an ordered set
        /// </summary>
        public override string ToString()
        {
            StringBuilder sb      = new StringBuilder("OrderedSet(");
            bool          isFirst = true;

            if (this.elems != null)
            {
                foreach (T val in this.elems)
                {
                    if (!isFirst)
                    {
                        sb.Append(", ");
                    }
                    PrettyPrinter.Format(sb, val);
                    isFirst = false;
                }
            }
            sb.Append(")");
            return(sb.ToString());
        }
Exemplo n.º 4
0
        /// <summary>
        /// Pretty printing
        /// </summary>
        /// <returns>A formatted string showing the type and fields of this value</returns>
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder(this.Sort.Name);

            // PrettyPrinter.FormatType(sb, this.GetType());
            sb.Append("(");
            bool isFirst = true;

            foreach (object obj in this.FieldValues())
            {
                if (!isFirst)
                {
                    sb.Append(", ");
                }
                PrettyPrinter.Format(sb, obj);
                isFirst = false;
            }
            sb.Append(")");
            return(sb.ToString());
        }
Exemplo n.º 5
0
        /// <exclude />
        public override string ToString()
        {
            StringBuilder sb      = new StringBuilder("Bag(");
            bool          isFirst = true;

            foreach (Pair <T, int> keyValue in this.representation)
            {
                if (!isFirst)
                {
                    sb.Append(", ");
                }
                PrettyPrinter.Format(sb, keyValue.First);
                if (keyValue.Second > 1)
                {
                    sb.Append(" (");
                    PrettyPrinter.Format(sb, keyValue.Second);
                    sb.Append(")");
                }
                isFirst = false;
            }
            sb.Append(")");
            return(sb.ToString());
        }
Exemplo n.º 6
0
        //ToString - - - - - - - - - - - - - - - - - - - - - - - - -
        /// <summary>
        /// Returns the map formatted in the form "Map(key_1 -> value_1, ..., key_n -> value_n)"
        /// </summary>
        public override string ToString()
        {
            StringBuilder sb      = new StringBuilder("Map(");
            bool          isFirst = true;

            if (this.elems != null)
            {
                foreach (Maplet keyValue in this.elems)
                {
                    if (!isFirst)
                    {
                        sb.Append(", ");
                    }
                    // sb.Append("(");
                    PrettyPrinter.Format(sb, keyValue.d.First);
                    sb.Append(" -> ");
                    PrettyPrinter.Format(sb, keyValue.d.Second);
                    // sb.Append(")");
                    isFirst = false;
                }
            }
            sb.Append(")");
            return(sb.ToString());
        }