Add() 공개 메소드

Adds an integer to a list.
public Add ( int value ) : int
value int The value that will be added.
리턴 int
		/// <summary>
		/// Returns an IntegerList whose elements are copies of the specified value.
		/// </summary>
		/// <param name="value">The value to copy multiple times in the list.</param>
		/// <param name="count">The number of times value should be copied.</param>
		/// <returns>An IntegerList with count number of elements, all of which are copies of value.</returns>
		public static IntegerList Repeat(int value, int count)
		{
			IntegerList result = new IntegerList();
			for (int i=0; i < count; i++)
			{
				result.Add(value);
			}
			return result;
		}
예제 #2
0
		public RuleRecord(Record record)
		{
			if (record.Entries.Count < 4)
				throw new CGTContentException("Invalid number of entries for rule");
			byte header = record.Entries[0].ToByteValue();
			if (header != 82) //'R'
				throw new CGTContentException("Invalid rule header");
			this.index = record.Entries[1].ToIntValue();
			this.nonterminal = record.Entries[2].ToIntValue();		
			//skip reserved empty entry
			this.symbols = new IntegerList();
			for (int i=4;i<record.Entries.Count;i++)
			{
				int symbol = record.Entries[i].ToIntValue();
				symbols.Add(symbol);
			}
		}
예제 #3
0
 /// <summary>
 /// Returns an IntegerList whose elements are copies of the specified value.
 /// </summary>
 /// <param name="value">The value to copy multiple times in the list.</param>
 /// <param name="count">The number of times value should be copied.</param>
 /// <returns>An IntegerList with count number of elements, all of which are copies of value.</returns>
 public static IntegerList Repeat(int value, int count)
 {
     IntegerList result = new IntegerList();
     for (int i = 0; i < count; i++)
     {
         result.Add(value);
     }
     return result;
 }