RemoveRange() public method

public RemoveRange ( int index, int count ) : void
index int
count int
return void
        public ContactListBuilder(ArrayList fullContactRegistry)
        {
            var boundsDetector = new ContactBoundsDetector();

            while(boundsDetector.NextBoundary(fullContactRegistry) > 0)
            {
                ArrayList contactDetails = new ArrayList();

                int boundary = boundsDetector.NextBoundary(fullContactRegistry);

                if (boundary > fullContactRegistry.Count)
                {
                    contacts.Add(new Contact(fullContactRegistry));
                    return;
                }

                for (int i=0; i<boundary; i++)
                {
                    contactDetails.Add(fullContactRegistry[i]);
                }

                contacts.Add(new Contact(contactDetails));

                fullContactRegistry.RemoveRange(0, boundary);
            }
        }
        public void fun1()
        {
            ArrayList a1 = new ArrayList();
            a1.Add(1);
            a1.Add('c');
            a1.Add("string1");

            ArrayList al2 = new ArrayList();
            al2.Add('a');
            al2.Add(5);

            int n = (int)a1[0];
            Console.WriteLine(n);
            a1[0] = 20;
            Console.WriteLine(a1.Count);
            Console.WriteLine(a1.Contains(55));
            Console.WriteLine(a1.IndexOf(55));
            //int[] num = (int[])a1.ToArray();

            a1.Add(45);
            a1.Add(12);
            a1.Add(67);

            a1.Insert(1, "new value");
            //a1.AddRange(al2);
            a1.InsertRange(1, al2);
            a1.Remove("string1");
            a1.RemoveAt(2);
            a1.RemoveRange(0, 2);

            foreach (object o in a1)
            {
                Console.WriteLine(o.ToString());
            }
        }
Example #3
0
 static void Main(string[] args)
 {
     ArrayList al = new ArrayList();
     al.Add("string");
     al.Add('B');
     al.Add(10);
     al.Add(DateTime.Now);
     ArrayList bl = new ArrayList(5);
     al.Remove('B');
     // 从al中删除第一个匹配的对象,如果al中不包含该对象,数组保持不变,不引发异常。
     al.Remove('B');
     al.RemoveAt(0);
     al.RemoveRange(0, 1);
     bl.Add(1);
     bl.Add(11);
     bl.Add(111);
     bl.Insert(4, 1111);
     int[] inttest = (int[])bl.ToArray(typeof(int));
     foreach(int it in inttest)
         Console.WriteLine(it);
     int[] inttest2 = new int[bl.Count];
     bl.CopyTo(inttest2);
     ArrayList cl = new ArrayList();
     cl.Add(1);
     cl.Add("Hello, World!");
     object[] ol = (object[])cl.ToArray(typeof(object));
     // stringp[] os = (string[])cl.ToArray(typeof(string));
     Console.WriteLine("The Capacity of new ArrayList: {0}", al.Capacity);
 }
Example #4
0
        public void Test(int arg)
        {
            ArrayList items = new ArrayList();
            items.Add(1);
            items.AddRange(1, 2, 3);
            items.Clear();
            bool b1 = items.Contains(2);
            items.Insert(0, 1);
            items.InsertRange(1, 0, 5);
            items.RemoveAt(4);
            items.RemoveRange(4, 3);
            items.Remove(1);
            object[] newItems = items.GetRange(5, 2);
            object[] newItems2 = items.GetRange(5, arg);

            List<int> numbers = new List<int>();
            numbers.Add(1);
            numbers.AddRange(1, 2, 3);
            numbers.Clear();
            bool b2 = numbers.Contains(4);
            numbers.Insert(1, 10);
            numbers.InsertRange(2, 10, 3);
            numbers.RemoveAt(4);
            numbers.RemoveRange(4, 2);
            int[] newNumbers = items.GetRange(5, 2);
            int[] newNumbers2 = items.GetRange(5, arg);

            string[] words = new string[5];
            words[0] = "hello";
            words[1] = "world";
            bool b3 = words.Contains("hi");
            string[] newWords = words.GetRange(5, 2);
            string[] newWords2 = words.GetRange(5, arg);
        }
Example #5
0
        private string Breaker(ArrayList Cell_String)
        {
            for (int i = 1; i < Cell_String.Count; i++)
            {
                if (Fun_Class.IsFunction(Cell_String[i].ToString()))
                {
                    int found = 1;
                    int start = i + 1;

                    while (found != 0)
                    {
                        start++;
                        if (Cell_String[start].ToString().Equals("("))
                            found++;
                        if (Cell_String[start].ToString().Equals(")"))
                            found--;
                    }
                    ArrayList atemp = new ArrayList(Cell_String.GetRange(i, start - i + 1));
                    Cell_String.RemoveRange(i, start - i + 1);
                    Cell_String.Insert(i, Breaker(atemp));
                }
            }

            //PrintArrayList(Cell_String);
            //System.Console.WriteLine(Cell_String[0].ToString());

            return Fun_Class.CallFunction(Cell_String);
        }
Example #6
0
 public void FilterResultsInInterval(DateTime Start, DateTime End, ArrayList List)
 {
     if (List == null)
         return;
     if (List.Count < 2)
         return;
     List.Sort();
     List.RemoveRange(1, List.Count-1);
 }
        protected void Button1_Click(object sender, EventArgs e)
        {
            linkeo linker = new linkeo();
            ArrayList campos = new ArrayList();
            ArrayList datos = new ArrayList();
            string resultado;
            int id;

            //especifico campos
            campos.Add("descripcion, ");
            campos.Add("unidad_medida, ");
            campos.Add("racion_unidad_medida, ");
            campos.Add("comentario ");

            //recolecto datos
            datos.Add(" ' ");
            datos.Add(this.TextBox1.Text);//des
            datos.Add(" ' ");
            datos.Add(" , ");
            datos.Add(this.DropDownList1.SelectedValue);//um
            datos.Add(" , ");
            datos.Add(this.TextBox2.Text);//ra um
            datos.Add(" , ");
            datos.Add(" ' ");
            datos.Add(this.TextBox5.Text);//com
            datos.Add(" ' ");

            resultado = linker.insercion_de_dataset("productos", campos, datos);
            Label1.Text = resultado;

            id = linker.obtener_id("productos");

            campos.RemoveRange(0, campos.Count);
            datos.RemoveRange(0, datos.Count);

            //especifico campos
            campos.Add("cantidad, ");
            campos.Add("indice_repo, ");
            campos.Add("comentario, ");
            campos.Add("id_producto ");

            //recolecto datos
            datos.Add(this.TextBox3.Text);//des
            datos.Add(" , ");
            datos.Add(this.TextBox4.Text);//um
            datos.Add(" , ");
            datos.Add(" ' ");
            datos.Add("stock inicial");//ra um
            datos.Add(" ' ");
            datos.Add(" , ");
            datos.Add(id);

            resultado = linker.insercion_de_dataset("stock", campos, datos);
            Label2.Text = resultado;
        }
        static void Main(string[] args)
        {
            ArrayList al = new ArrayList();
            al.Add("Paris");
            al.Add("Ottowa");
            al.AddRange(new string[] { "Rome", "Tokyo", "Tunis", "Canberra" });

            Console.WriteLine("Count:    {0}", al.Count);
            Console.WriteLine("Capacity: {0}", al.Capacity);

            Console.WriteLine("Print values using foreach");
            PrintValues(al);
            Console.WriteLine("Print values using IEnumerator");
            PrintValuesByEnumerator(al);

            // Get second item in list as string
            string str = (string)al[1];    // need to cast, would also unbox if stored type was value type
            Console.WriteLine("al[1] = {0}", str);

            // Get first three items
            ArrayList firstThree = al.GetRange(0, 3);
            PrintValues(firstThree);

            // Remove next two
            al.RemoveRange(3, 2);
            PrintValues(al);

            // Get, insert and remove
            object itemOne = al[1];
            al.Insert(1, "Moscow");
            al.RemoveAt(2);
            PrintValues(al);

            // Sort
            al.Sort();
            PrintValues(al);

            // Search
            int targetIndex = al.BinarySearch("Moscow");
            Console.WriteLine("Index of Moscow: {0}", targetIndex);

            // Trim capacity
            al.TrimToSize();
            Console.WriteLine("Count:    {0}", al.Count);
            Console.WriteLine("Capacity: {0}", al.Capacity);

            // Creates a new ArrayList with five elements and initialize each element with a value.
            ArrayList al2 = ArrayList.Repeat("Boston", 5);   // static method
            PrintValues(al2);
        }
Example #9
0
 public override Pair<IList, bool> Combine(IList oldh, IList newh) {
   ArrayList result = new ArrayList();
   result.AddRange(oldh);
   foreach(object newit in newh) {
     if(!result.Contains(newit)) {
       result.Add(newit);
     }
   }
   result.Sort(GetComparer());
   bool done = result.Count >= Max;
   if( done ) {
     result.RemoveRange(Max, result.Count - Max);
   }
   return new Pair<IList,bool>(result, done);
 }
        /// <summary>
        /// Collaps sequence of single push actions into one multiple-push action
        /// </summary>
        private void CollapsPushActions(ArrayList actionRecord) {

            int i = 0;
            bool isPush;
            
            while (i<(actionRecord.Count-1)) {
                
                isPush = actionRecord[i] is ActionPush;
                if (isPush) {
                    
                    int j = i;
                    int count = 1;
                    
                    do {
                        i++;
                        if (i<actionRecord.Count) {
                            isPush=(actionRecord[i] is ActionPush);
                            if (isPush) count++;
                        }
                    } while ((isPush)&&(i<actionRecord.Count));
                    
                    if (count>1) {
                        ActionPush[] pushList = new ActionPush[count];
                        actionRecord.CopyTo(j,pushList,0,count);
                        
                        actionRecord.RemoveRange(j,count);                      
                        ActionPushList pl = new ActionPushList(pushList);                   
                        actionRecord.Insert(j,pl);
                        
                        i=j+1;                      
                    }
                    
                    
                } else {
                    
                    // recursively step through functions inner actions
                    ActionDefineFunction f = actionRecord[i] as ActionDefineFunction;
                    if (f!=null) CollapsPushActions(f.ActionRecord);
                    
                    // and function2 of course
                    ActionDefineFunction2 f2 = actionRecord[i] as ActionDefineFunction2;
                    if (f2!=null) CollapsPushActions(f2.ActionRecord);
                    i++;
                }
            }

        }
Example #11
0
        public static string tailString(string toTail, int lines)
        {
            string[] textArray = toTail.Split('\n');
             ArrayList textList = new ArrayList(textArray);
             string returnText = "";

             if (textList.Count > lines)
             {
            textList.RemoveRange(0, (textList.Count - lines));
            textArray = (string[])textList.ToArray(typeof(string));
            returnText = String.Join("\n", textArray);
             }
             else
             {
            returnText = toTail;
             }
             return returnText;
        }
Example #12
0
 public void BindDropdowns(string[] headerItems)
 {
     try
     {
         ArrayList headers = new ArrayList();
         headers.AddRange(headerItems);
         headers.RemoveRange(headers.Count - 20, 20);
         for (int i = 0; i < GridFieldmap.Rows.Count; i++)
         {
             TableTextFields.Clear();
             TableTextFields.AddRange(headers);
             DropDownList ddlContactMasterFields = (DropDownList)this.GridFieldmap.Rows[i].FindControl("ddlContactMasterFields");
             Label headerText = (Label)this.GridFieldmap.Rows[i].FindControl("lblHeaderField");
             ddlContactMasterFields.Items.Clear();
             ddlContactMasterFields.Items.Add(new ListItem("--Select--", "--Select--"));
             ddlContactMasterFields.DataSource = TableTextFields;
             ddlContactMasterFields.DataBind();
             DataTable dtfields = AdvanceManageFieldBase.SelectCustomFields(ConnectionString);
             dtfields.AsEnumerable().ToList().ForEach(delegate(DataRow drRow) { ddlContactMasterFields.Items.Add(new ListItem(drRow["FieldName"].ToString(), drRow["ContactFieldName"].ToString())); });
             string clmName = headerText.Text.Replace(" ", string.Empty);
             if (clmName == "Email")
                 clmName = "EmailAddress";
             else if (clmName == "ResponseChannel")
                 clmName = "DirectMailPaper";
             ListItem mapItem = ddlContactMasterFields.Items.FindByText(clmName);
             if (mapItem != null)
                 ddlContactMasterFields.Items.FindByText(mapItem.Text).Selected = true;
             else
             {
                 ddlContactMasterFields.SelectedIndex = 0;
                 LinkButton lbtnRemove = (LinkButton)GridFieldmap.Rows[i].FindControl("lbtnRemoveMapping");
                 lbtnRemove.Enabled = false;
                 lbtnRemove.Attributes.Add("style", "text-decoration:none;");
             }
         }
         updatePanelFieldmap.Update();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #13
0
        public ArrayLists()
        {
            ArrayList arryList1 = new ArrayList();

            //add() to add individual at the end of data
            arryList1.Add(1);
            arryList1.Add("Two");
            arryList1.Add(3);
            arryList1.Add(4.5);

            ArrayList arryList2 = new ArrayList();
            arryList2.Add(100);
            arryList2.Add(200);

            //adding an entire collection
            ArrayList arrylist = new ArrayList();
            arrylist.AddRange(arryList2);

            //access individual
            var firstElement = (int) arryList1[0];
            var secondElement = (string) arryList1[1];
            var thirdElement = (int) arryList1[2];
            var forthElement = (float) arryList1[3];

            //accesss using loop
            foreach (var val in arryList1)
            {
                Console.WriteLine(val);
            }

            for (int i = 0; i < arryList1.Count; i++)
            {
                Console.WriteLine(arryList1[i]);
            }

            //remove item using index
            arryList1.RemoveAt(2); //remove value two

            arryList1.RemoveRange(0,2); //remove two elements starting from 1st item (0 index)
        }
Example #14
0
        static void Main(string[] args)
        {
            var arrayLst = new ArrayList();

            arrayLst.Add(1);
            PrintArrayList(arrayLst);

            arrayLst.AddRange(new[] { 2, 3, 7, 6, 5, 4 });
            PrintArrayList(arrayLst);

            arrayLst.Insert(index: 0, value: 0);
            PrintArrayList(arrayLst);

            arrayLst.RemoveAt(index: 4);
            PrintArrayList(arrayLst);

            arrayLst.Remove(obj: 1);
            PrintArrayList(arrayLst);

            arrayLst.RemoveRange(index: 2, count: 3);
            PrintArrayList(arrayLst);

            arrayLst.Reverse();
            PrintArrayList(arrayLst);

            arrayLst.Sort();
            PrintArrayList(arrayLst);

            bool hasTwo = arrayLst.Contains(2);
            Console.WriteLine(hasTwo);

            int two = (int)arrayLst[1];
            Console.WriteLine(two);

            Console.ReadLine();
        }
Example #15
0
        internal static String Reduce(String path)
        {
            // ignore query string
            String queryString = null;
            if (path != null)
            {
                int iqs = path.IndexOf('?');
                if (iqs >= 0)
                {
                    queryString = path.Substring(iqs);
                    path = path.Substring(0, iqs);
                }
            }

            int length = path.Length;
            int examine;

            // Make sure we don't have any back slashes
            path = path.Replace('\\', '/');

            // quickly rule out situations in which there are no . or ..

            for (examine = 0; ; examine++)
            {
                examine = path.IndexOf('.', examine);
                if (examine < 0)
                {
                    return (queryString != null) ? (path + queryString) : path;
                }

                if ((examine == 0 || path[examine - 1] == '/')
                    && (examine + 1 == length || path[examine + 1] == '/' ||
                        (path[examine + 1] == '.' && (examine + 2 == length || path[examine + 2] == '/'))))
                {
                    break;
                }
            }

            // OK, we found a . or .. so process it:

            ArrayList list = new ArrayList();
            StringBuilder sb = new StringBuilder();
            int start;
            examine = 0;

            for (;;)
            {
                start = examine;
                examine = path.IndexOf('/', start + 1);

                if (examine < 0)
                {
                    examine = length;
                }

                if (examine - start <= 3 &&
                    (examine < 1 || path[examine - 1] == '.') &&
                    (start + 1 >= length || path[start + 1] == '.'))
                {
                    if (examine - start == 3)
                    {
                        if (list.Count == 0)
                        {
                            throw new Exception(SR.GetString(SR.UrlPath_CannotExitUpTopDirectory));
                        }

                        sb.Length = (int)list[list.Count - 1];
                        list.RemoveRange(list.Count - 1, 1);
                    }
                }
                else
                {
                    list.Add(sb.Length);

                    sb.Append(path, start, examine - start);
                }

                if (examine == length)
                {
                    break;
                }
            }

            return sb.ToString() + queryString;
        }
Example #16
0
        /// <summary>
        /// Adds an <see cref="XmlDocument" /> to the map.
        /// </summary>
        /// <remarks>
        /// An <see cref="XmlDocument" /> can only be added to the map once.
        /// </remarks>
        public void Add(XmlDocument doc) {
            // check for non-backed documents
            if (String.IsNullOrEmpty(doc.BaseURI)) {
                return;
            }

            // convert URI to absolute URI
            Uri uri = new Uri(doc.BaseURI);
            string fileName = uri.AbsoluteUri;

            // prevent duplicate mapping
            if (FileIsMapped(fileName)) {
                // do not re-map the file a 2nd time
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "XML document '{0}' has already been mapped.", fileName));
           }

            Hashtable map = new Hashtable();

            string parentXPath = "/"; // default to root
            string previousXPath = "";
            int previousDepth = 0;

            // Load text reader.
            XmlTextReader reader = new XmlTextReader(fileName);
            try {
                map.Add((object) "/", (object) new TextPosition(1, 1));

                ArrayList indexAtDepth = new ArrayList();

                // loop thru all nodes in the document
                while (reader.Read()) {
                    // Ignore nodes we aren't interested in
                    if ((reader.NodeType != XmlNodeType.Whitespace) &&
                        (reader.NodeType != XmlNodeType.EndElement) &&
                        (reader.NodeType != XmlNodeType.ProcessingInstruction) &&
                        (reader.NodeType != XmlNodeType.XmlDeclaration) &&
                        (reader.NodeType != XmlNodeType.DocumentType)) {

                        int level = reader.Depth;
                        string currentXPath = "";

                        // If we are higher than before
                        if (reader.Depth < previousDepth) {
                            // Clear vars for new depth
                            string[] list = parentXPath.Split('/');
                            string newXPath = ""; // once appended to / will be root node

                            for (int j = 1; j < level+1; j++) {
                                newXPath += "/" + list[j];
                            }

                            // higher than before so trim xpath\
                            parentXPath = newXPath; // one up from before

                            // clear indexes for depth greater than ours
                            indexAtDepth.RemoveRange(level+1, indexAtDepth.Count - (level+1));
                        } else if (reader.Depth > previousDepth) {
                            // we are lower
                            parentXPath = previousXPath;
                        }

                        // End depth setup
                        // Setup up index array
                        // add any needed extra items ( usually only 1 )
                        // would have used array but not sure what maximum depth will be beforehand
                        for (int index = indexAtDepth.Count; index < level+1; index++) {
                            indexAtDepth.Add(0);
                        }

                        // Set child index
                        if ((int) indexAtDepth[level] == 0) {
                            // first time thru
                            indexAtDepth[level] = 1;
                        } else {
                            indexAtDepth[level] = (int) indexAtDepth[level] + 1; // lower so append to xpath
                        }

                        // Do actual XPath generation
                        if (parentXPath.EndsWith("/")) {
                            currentXPath = parentXPath;
                        } else {
                            currentXPath = parentXPath + "/"; // add seperator
                        }

                        // Set the final XPath
                        currentXPath += "child::node()[" + indexAtDepth[level] + "]";

                        // Add to our hash structures
                        map.Add((object) currentXPath, (object) new TextPosition(reader.LineNumber, reader.LinePosition));

                        // setup up loop vars for next iteration
                        previousXPath = currentXPath;
                        previousDepth = reader.Depth;
                    }
                }
            } finally {
                reader.Close();
            }

            // add map at the end to prevent adding maps that had errors
            _fileMap.Add(fileName, map);
        }
Example #17
0
 private void ReduceStack(ArrayList stack)
 {
     for (var i = 1; i < stack.Count; i++)
     {
         var prev = (string) stack[i - 1];
         var cur = (string)stack[i];
         if (prev.StartsWith("st") && cur.StartsWith("st"))
         {
             var a = int.Parse(prev.Split(' ')[1]);
             var b = int.Parse(cur.Split(' ')[1]);
             stack.RemoveRange(i - 1, 2);
             if (a + b != 0)
                 stack.Insert(i - 1, "st " + (a + b));
             i--;
         }
     }
 }
Example #18
0
 private ArrayList truncateList(ArrayList list, int maxCount)
 {
     if (list.Count > maxCount)
     {
         list.RemoveRange(maxCount, list.Count - maxCount);
     }
     return list;
 }
        public void reduceDuplicateAndUpdateIndexTable(ArrayList index_row_to_find_index, string find_word)
        {
            List<int> index_list = new List<int>();
            foreach (Index index in index_row_to_find_index)
            {
                if (index.word == find_word)
                {
                    index_list.Add(index_row_to_find_index.IndexOf(index));
                }
            }

            if (index_list.Count > 1)
            {
                ((Index)index_row_to_find_index[index_list[0]]).hits = index_list.Count;
                for (int count = 1; count < index_list.Count; count++)
                {
                    foreach (string index_path in ((Index)index_row_to_find_index[index_list[count]]).index)
                    {
                        if (!((Index)index_row_to_find_index[index_list[0]]).index.Contains(index_path))
                            ((Index)index_row_to_find_index[index_list[0]]).index.Add(index_path);
                    }
                }

                index_row_to_find_index.RemoveRange(index_list[1], index_list.Count - 1);
            }
          
        }
Example #20
0
    /// <summary>
    /// Solve given sudoku grid and solutions upto maximum number specified
    /// </summary>
    /// <param name="g"></param>
    /// <returns></returns>
    public static IList Solve(Grid grid, int maxSolutions)
    {
      ArrayList solutions = new ArrayList();
      // If grid is solved then return as solution
      if (grid.CountFilledCells() == (grid.CellsInRow * grid.CellsInRow))
      {
        solutions.Add(grid.Clone());
        return solutions;
      }

      // Solve singles
      //Singles(grid);

      // Choose unsolved cell
      int leastCandidatesRow = -1;
      int leastCandidatesColumn = -1;
      IList leastCandidates = null;

      for (int row = 0; row < grid.CellsInRow; row++)
      {
        for (int column = 0; column < grid.CellsInRow; column++)
        {
          if (grid.cells[row, column] == 0)
          {
            IList candidates = grid.Possibilities(row, column);

            // If cell has no possible value then grid is not solvable so quit now
            if (candidates.Count == 0)
            {
              return solutions;
            }
            else if (leastCandidates == null || leastCandidates.Count > candidates.Count)
            {
              leastCandidatesRow = row;
              leastCandidatesColumn = column;
              leastCandidates = candidates;
            }
          }
        }
      }

      // For all candidates of unsolved cell
      if (leastCandidates != null)
      {
        while (leastCandidates.Count > 0)
        {
          // Set candidate
          int candidateIndex = random.Next(leastCandidates.Count);
          grid.cells[leastCandidatesRow, leastCandidatesColumn] = (int)leastCandidates[candidateIndex];
          leastCandidates.RemoveAt(candidateIndex);

          Grid nextLevelGrid = (Grid)grid.Clone();

          IList nextLevelSolutions = Solve(nextLevelGrid, maxSolutions);

          solutions.AddRange(nextLevelSolutions);

          // Trim number of solutions so we don't exceed maximum required
          if (solutions.Count > maxSolutions)
          {
            solutions.RemoveRange(0, solutions.Count - maxSolutions);
          }

          if (solutions.Count == maxSolutions)
          {
            return solutions;
          }
        }
      }
      return solutions;
    }
Example #21
0
        byte[] SerializeScanData()
        {
            // Combine all ScanData data
            ScanData[] asd = m_asdEven;
            ArrayList alsSideCodes = new ArrayList();
            ArrayList alsIclr = new ArrayList();
            foreach (ScanData sd in asd) {
                alsSideCodes.AddRange(sd.GetSideCodes());
                alsIclr.AddRange(sd.GetColorData());
            }

            // Make ops. Add side codes to op stream to unify stream.
            ArrayList alsOpsT = SerializeOps(asd);
            ArrayList alsOps = new ArrayList();
            foreach (Op op in alsOpsT) {
                alsOps.Add(op);
                if (op >= Op.EvenSide1 && op <= Op.EvenSide16) {
                    int csc = (((op - Op.EvenSide1) + 1) + 1) / 2;
                    for (int isc = 0; isc < csc; isc++)
                        alsOps.Add(alsSideCodes[isc]);
                    alsSideCodes.RemoveRange(0, csc);
                }
                if (op >= Op.OddSide1 && op <= Op.OddSide16) {
                    int csc = (((op - Op.OddSide1) + 1) + 1) / 2;
                    for (int isc = 0; isc < csc; isc++)
                        alsOps.Add(alsSideCodes[isc]);
                    alsSideCodes.RemoveRange(0, csc);
                }
            }

            // Remember count of bytes needed for aligned data. Add one for both alignements.
            // This is needed during compiling. Make it an even count.
            int cbaiclrUnpacked = ((alsIclr.Count + 1) + 1) & ~1;

            // Create the packed, unaligned color data
            ArrayList alsIclrPacked = new ArrayList();
            foreach (int iclr in alsIclr) {
                if (iclr != s_iclrNotAssigned)
                    alsIclrPacked.Add(iclr);
            }

            // Serialize:
            //	public ushort ibaiclr;
            //  public ushort cbaiclrUnpacked;
            //	public byte[] aop;
            //  public byte[] aiclr;

            // Write placeholders
            BinaryWriter bwtr = new BinaryWriter(new MemoryStream());
            bwtr.Write((ushort)0);
            bwtr.Write((ushort)0);

            // Data
            foreach (Op op in alsOps)
                bwtr.Write((byte)op);
            int ibaiclr = (ushort)bwtr.BaseStream.Position;
            foreach (int iclr in alsIclrPacked)
                bwtr.Write((byte)iclr);

            // Fix up pointers
            int cb = (int)bwtr.BaseStream.Length;
            bwtr.BaseStream.Seek(0, SeekOrigin.Begin);
            bwtr.Write((ushort)Misc.SwapUShort((ushort)ibaiclr));
            bwtr.Write((ushort)Misc.SwapUShort((ushort)cbaiclrUnpacked));

            // Return buffer
            byte[] ab = new byte[cb];
            bwtr.BaseStream.Seek(0, SeekOrigin.Begin);
            bwtr.BaseStream.Read(ab, 0, cb);
            bwtr.Close();
            return ab;
        }
Example #22
0
        ArrayList SerializeOps(ScanData[] asd)
        {
            // Serialize ops. Remove trailing and beginning transparency between scans
            // and replace with NextScan ops.
            ArrayList alsOps = new ArrayList();
            ArrayList alsT = new ArrayList();
            int cpSkip = -1;
            foreach (ScanData sd in asd) {
                alsT.Clear();
                alsT.AddRange(sd.GetOps());

                // If cpSkip != -1 then we've removed some trailing transparency
                // from the last scan. Search the start of this new scan.
                if (cpSkip != -1) {
                    int iop = 0;
                    for (; iop < alsT.Count; iop++) {
                        // Add up the transparency
                        Op op = (Op)alsT[iop];
                        if (op >= Op.Transparent1 && op <= Op.Transparent32) {
                            cpSkip += op - Op.Transparent1 + 1;
                            continue;
                        }
                        break;
                    }

                    // Hit a non-transparent op or end of list. Remove found transparent ops
                    alsT.RemoveRange(0, iop);

                    // Max is...
                    int cpMax = m_cx > s_cpNextScanMax ? s_cpNextScanMax : m_cx;

                    // If there is too much transparency to endcode in one
                    // NextScan op, cut into pieces.
                    int cpExtra = cpSkip - cpMax;
                    if (cpExtra > 0) {
                        cpSkip -= cpExtra;
                        while (cpExtra != 0) {
                            int cpT = cpExtra <= s_cpTransparentMax ? cpExtra : s_cpTransparentMax;
                            alsT.Insert(0, Op.Transparent1 + cpT - 1);
                            cpExtra -= cpT;
                        }
                    }

                    // Insert NextScan op
                    alsT.Insert(0, Op.NextScan0 + cpSkip);
                }

                // Now remove trailing transparency if there is any.
                cpSkip = 0;
                int iopTrailing = -1;
                for (int iop = 0; iop < alsT.Count; iop++) {
                    Op op = (Op)alsT[iop];
                    if (op >= Op.Transparent1 && op <= Op.Transparent32) {
                        if (iopTrailing == -1)
                            iopTrailing = iop;
                        cpSkip += op - Op.Transparent1 + 1;
                        continue;
                    } else {
                        iopTrailing = -1;
                        cpSkip = 0;
                    }
                }

                // Remove the trailing transparency
                if (iopTrailing != -1) {
                    // Remove this transparency
                    alsT.RemoveRange(iopTrailing, alsT.Count - iopTrailing);

                    // If we've skipped more than the largest EndScan, insert some
                    // transparency.
                    int cpExtra = cpSkip - s_cpNextScanMax;
                    if (cpExtra > 0) {
                        cpSkip -= cpExtra;
                        while (cpExtra != 0) {
                            int cpT = cpExtra <= s_cpTransparentMax ? cpExtra : s_cpTransparentMax;
                            alsT.Add(Op.Transparent1 + cpT - 1);
                            cpExtra -= cpT;
                        }
                    }
                }

                // alsT is ready to add to the ops list
                alsOps.AddRange(alsT);
            }

            // Add End op
            alsOps.Add(Op.End);
            return alsOps;
        }
Example #23
0
		public void TestEnumerator ()
		{
			String [] s1 = { "this", "is", "a", "test" };
			ArrayList al1 = new ArrayList (s1);
			IEnumerator en = al1.GetEnumerator ();
			en.MoveNext ();
			al1.Add ("something");
			try {
				en.MoveNext ();
				Assert.Fail ("Add() didn't invalidate the enumerator");
			} catch (InvalidOperationException) {
				// do nothing...this is what we expect
			}

			en = al1.GetEnumerator ();
			en.MoveNext ();
			al1.AddRange (al1);
			try {
				en.MoveNext ();
				Assert.Fail ("AddRange() didn't invalidate the enumerator");
			} catch (InvalidOperationException) {
				// do nothing...this is what we expect
			}

			en = al1.GetEnumerator ();
			en.MoveNext ();
			al1.Clear ();
			try {
				en.MoveNext ();
				Assert.Fail ("Clear() didn't invalidate the enumerator");
			} catch (InvalidOperationException) {
				// do nothing...this is what we expect
			}

			al1 = new ArrayList (s1);
			en = al1.GetEnumerator ();
			en.MoveNext ();
			al1.Insert (0, "new first");
			try {
				en.MoveNext ();
				Assert.Fail ("Insert() didn't invalidate the enumerator");
			} catch (InvalidOperationException) {
				// do nothing...this is what we expect
			}

			en = al1.GetEnumerator ();
			en.MoveNext ();
			al1.InsertRange (0, al1);
			try {
				en.MoveNext ();
				Assert.Fail ("InsertRange() didn't invalidate the enumerator");
			} catch (InvalidOperationException) {
				// do nothing...this is what we expect
			}

			en = al1.GetEnumerator ();
			en.MoveNext ();
			al1.Remove ("this");
			try {
				en.MoveNext ();
				Assert.Fail ("Remove() didn't invalidate the enumerator");
			} catch (InvalidOperationException) {
				// do nothing...this is what we expect
			}

			en = al1.GetEnumerator ();
			en.MoveNext ();
			al1.RemoveAt (2);
			try {
				en.MoveNext ();
				Assert.Fail ("RemoveAt() didn't invalidate the enumerator");
			} catch (InvalidOperationException) {
				// do nothing...this is what we expect
			}

			en = al1.GetEnumerator ();
			en.MoveNext ();
			al1.RemoveRange (1, 1);
			try {
				en.MoveNext ();
				Assert.Fail ("RemoveRange() didn't invalidate the enumerator");
			} catch (InvalidOperationException) {
				// do nothing...this is what we expect
			}

			en = al1.GetEnumerator ();
			en.MoveNext ();
			al1.Reverse ();
			try {
				en.MoveNext ();
				Assert.Fail ("Reverse() didn't invalidate the enumerator");
			} catch (InvalidOperationException) {
				// do nothing...this is what we expect
			}

			en = al1.GetEnumerator ();
			en.MoveNext ();
			al1.Sort ();
			try {
				en.MoveNext ();
				Assert.Fail ("Sort() didn't invalidate the enumerator");
			} catch (InvalidOperationException) {
				// do nothing...this is what we expect
			}
		}
Example #24
0
		public void RemoveRange_CountOverflow ()
		{
			ArrayList al = new ArrayList ();
			al.Add (this);
			al.RemoveRange (1, Int32.MaxValue);
		}
Example #25
0
        /* NOT COMPLETE YET (Cell Reference,A1) 
         * THIS NEED TO BE SOLVED BY UI! 
         * The UI team needs to setup a mathod that takes a Cell Reference as a string and return the formula.
         */
        private ArrayList Reformat(ArrayList Parts)
        {
            #region SECTION REMOVER ()
            for (int i = 0; i < Parts.Count; i++)
            {
                int second = i - 1;
                if (second == -1)
                    second = 0;
                if (Parts[i].ToString().Equals("(") && !Fun_Class.IsFunction(Parts[second].ToString()) && !IsNumber(Parts[second].ToString()))
                {
                    //PrintArrayList(Parts);

                    int found = 1;
                    int start = i;

                    while (found != 0)
                    {
                        start++;
                        if (Parts[start].ToString().Equals("("))
                            found++;
                        if (Parts[start].ToString().Equals(")"))
                            found--;
                    }
                    ArrayList atemp = new ArrayList(Parts.GetRange(i + 1, start - i + 1 - 2));
                    Parts.RemoveRange(i, start - i + 1);
                    Parts.InsertRange(i, Reformat(atemp));
                }
            }
            #endregion
            #region SHORTCUT REMOVER * and /
            for (int i = 0; i < Parts.Count; i++)
            {
                string function;
                if (Parts[i].ToString().Equals("*") || Parts[i].ToString().Equals("/"))
                {
                    //PrintArrayList(Parts);

                    if (Parts[i].ToString().Equals("*"))
                        function = "MUL";
                    else
                        function = "DIV";

                    try
                    {
                        int first = i - 1, second = i + 2;
                        if ((i + 2) >= Parts.Count)
                            second--;
                        if (Parts[first].ToString().Equals(")") && !Parts[second].ToString().Equals("("))
                        {
                            int found = 1;
                            int start = i - 1;

                            while (found != 0)
                            {
                                start--;
                                if (Parts[start].ToString().Equals(")"))
                                    found++;
                                if (Parts[start].ToString().Equals("("))
                                    found--;
                            }

                            Parts.Insert(i, ")");
                            Parts.Insert(i, Parts[i + 2]);
                            Parts.Insert(i, ",");
                            Parts.InsertRange(i, Parts.GetRange(start - 1, i - start + 1));
                            Parts.Insert(i, "(");
                            Parts.Insert(i, function);

                            Parts.RemoveAt(i + (i - start + 1) + 5);
                            Parts.RemoveAt(i + (i - start + 1) + 5);
                            Parts.RemoveRange(start - 1, i - start + 1);
                        }
                        else
                        {
                            if (!Parts[first].ToString().Equals(")") && Parts[second].ToString().Equals("("))
                            {
                                int found = 1;
                                int start = i + 2;

                                while (found != 0)
                                {
                                    start++;
                                    if (Parts[start].ToString().Equals("("))
                                        found++;
                                    if (Parts[start].ToString().Equals(")"))
                                        found--;
                                }

                                Parts.Insert(start + i, ")");
                                Parts.Insert(i + 1, ",");
                                Parts.Insert(i + 1, Parts[i - 1]);
                                Parts.Insert(i + 1, "(");
                                Parts.Insert(i + 1, function);

                                Parts.RemoveAt(i - 1);
                                Parts.RemoveAt(i - 1);
                            }
                            else
                            {
                                if (!Parts[first].ToString().Equals(")") && !Parts[second].ToString().Equals("("))
                                {
                                    Parts.Insert(i, ")");
                                    Parts.Insert(i, Parts[i + 2]);
                                    Parts.Insert(i, ",");
                                    Parts.Insert(i, Parts[i - 1]);
                                    Parts.Insert(i, "(");
                                    Parts.Insert(i, function);

                                    Parts.RemoveAt(i + 6);
                                    Parts.RemoveAt(i + 6);
                                    Parts.RemoveAt(i - 1);
                                }
                                else
                                {
                                    if (Parts[first].ToString().Equals(")") && Parts[second].ToString().Equals("("))
                                    {
                                        int found = 1;
                                        int start = i + 2;

                                        while (found != 0)
                                        {
                                            start++;
                                            if (Parts[start].ToString().Equals("("))
                                                found++;
                                            if (Parts[start].ToString().Equals(")"))
                                                found--;
                                        }

                                        Parts.Insert(start + 1, ")");
                                        Parts[i] = ",";

                                        found = 1;
                                        start = i - 1;

                                        while (found != 0)
                                        {
                                            start--;
                                            if (Parts[start].ToString().Equals(")"))
                                                found++;
                                            if (Parts[start].ToString().Equals("("))
                                                found--;
                                        }

                                        Parts.Insert(start - 1, "(");
                                        Parts.Insert(start - 1, function);
                                    }
                                }
                            }
                        }
                    }
                    catch
                    {
                        OutFile.WriteLine("ERROR: INCORRECT INPUT STRING"); //ERROR: INCORRECT INPUT STRING
                        Form1.Step("ERROR: INCORRECT INPUT STRING");
                        return Tokenize(Base_String);
                    }
                }
            }
            #endregion
            #region SHORTCUT REMOVER + and -
            for (int i = 0; i < Parts.Count; i++)
            { //SHORTCUT REMOVER
                string function;
                if (Parts[i].ToString().Equals("+") || Parts[i].ToString().Equals("-"))
                {
                    //PrintArrayList(Parts);

                    if (Parts[i].ToString().Equals("+"))
                        function = "ADD";
                    else
                        function = "SUB";

                    try
                    {
                        int first = i - 1, second = i + 2;
                        if ((i + 2) >= Parts.Count)
                            second--;
                        if (Parts[first].ToString().Equals(")") && !Parts[second].ToString().Equals("("))
                        {
                            int found = 1;
                            int start = i - 1;

                            while (found != 0)
                            {
                                start--;
                                if (Parts[start].ToString().Equals(")"))
                                    found++;
                                if (Parts[start].ToString().Equals("("))
                                    found--;
                            }

                            Parts.Insert(i, ")");
                            Parts.Insert(i, Parts[i + 2]);
                            Parts.Insert(i, ",");
                            Parts.InsertRange(i, Parts.GetRange(start - 1, i - start + 1));
                            Parts.Insert(i, "(");
                            Parts.Insert(i, function);

                            Parts.RemoveAt(i + (i - start + 1) + 5);
                            Parts.RemoveAt(i + (i - start + 1) + 5);
                            Parts.RemoveRange(start - 1, i - start + 1);
                        }
                        else
                        {
                            if (!Parts[first].ToString().Equals(")") && Parts[second].ToString().Equals("("))
                            {
                                int found = 1;
                                int start = i + 2;

                                while (found != 0)
                                {
                                    start++;
                                    if (Parts[start].ToString().Equals("("))
                                        found++;
                                    if (Parts[start].ToString().Equals(")"))
                                        found--;
                                }

                                Parts.Insert(start + i, ")");
                                Parts.Insert(i + 1, ",");
                                Parts.Insert(i + 1, Parts[i - 1]);
                                Parts.Insert(i + 1, "(");
                                Parts.Insert(i + 1, function);

                                Parts.RemoveAt(i - 1);
                                Parts.RemoveAt(i - 1);
                            }
                            else
                            {
                                if (!Parts[first].ToString().Equals(")") && !Parts[second].ToString().Equals("("))
                                {
                                    Parts.Insert(i, ")");
                                    Parts.Insert(i, Parts[i + 2]);
                                    Parts.Insert(i, ",");
                                    Parts.Insert(i, Parts[i - 1]);
                                    Parts.Insert(i, "(");
                                    Parts.Insert(i, function);

                                    Parts.RemoveAt(i + 6);
                                    Parts.RemoveAt(i + 6);
                                    Parts.RemoveAt(i - 1);
                                }
                                else
                                {
                                    if (Parts[first].ToString().Equals(")") && Parts[second].ToString().Equals("("))
                                    {
                                        int found = 1;
                                        int start = i + 2;

                                        while (found != 0)
                                        {
                                            start++;
                                            if (Parts[start].ToString().Equals("("))
                                                found++;
                                            if (Parts[start].ToString().Equals(")"))
                                                found--;
                                        }

                                        Parts.Insert(start + 1, ")");
                                        Parts[i] = ",";

                                        found = 1;
                                        start = i - 1;

                                        while (found != 0)
                                        {
                                            start--;
                                            if (Parts[start].ToString().Equals(")"))
                                                found++;
                                            if (Parts[start].ToString().Equals("("))
                                                found--;
                                        }

                                        Parts.Insert(start - 1, "(");
                                        Parts.Insert(start - 1, function);
                                    }
                                }
                            }
                        }
                    }
                    catch
                    {
                        OutFile.WriteLine("ERROR: INCORRECT INPUT STRING"); //ERROR: INCORRECT INPUT STRING
                        Form1.Step("ERROR: INCORRECT INPUT STRING");
                        return Tokenize(Base_String);
                    }
                }
            }
            #endregion
            #region SHORTCUT REMOVER :
            for (int i = 0; i < Parts.Count; i++)
            { //SHORTCUT REMOVER 1
                if (Parts[i].ToString().Contains(":"))
                {
                    //PrintArrayList(Parts);

                    char c = Convert.ToChar(Parts[i].ToString().Substring(0, 1));
                    int t1 = Convert.ToInt32(Parts[i].ToString().Split(':')[0].Substring(1));
                    int t2 = Convert.ToInt32(Parts[i].ToString().Split(':')[1].Substring(1));

                    Parts.RemoveAt(i);
                    for (int j = t2; j >= t1; j--)
                    {
                        Parts.Insert(i, c + j.ToString());
                        if (j != t1)
                            Parts.Insert(i, ",");
                    }
                }
            }
            #endregion
            for (int i = 0; i < Parts.Count; i++)
            { //CELL REFERENCE
                if (Base_Cell.CompareTo(Parts[i].ToString().ToUpper()) == 0)
                {
                    OutFile.WriteLine("ERROR: CIRCULAR REFERENCE");
                    Form1.Step("ERROR: CIRCULAR REFERENCE");
                    //ERROR: CIRCULAR REFERENCE
                    return Parts;
                }
                if (IsCellReference(Parts[i].ToString()))
                {
                    OutFile.WriteLine("Cell Reference");
                    Form1.Step("Cell Reference");
                    //Console.WriteLine("BaseCell= " + Base_Cell);
                    //Console.WriteLine("CellReference= " + Parts[i].ToString());

                    string cell_ref = Parts[i].ToString().ToUpper();

                    Parts.RemoveAt(i);
                    //string temp = "=1+2";//temp will equal the output of the UI's function
                    string temp = Form1.getCellFormula(cell_ref);

                    OutFile.WriteLine(cell_ref + " -> " + temp);
                    Form1.Step(cell_ref + " -> " + temp);

                    if (temp[0] == '=')
                    {
                        //Cell has a formula
                        Parts.InsertRange(i, Reformat(Tokenize(temp)));

                        OutFile.WriteLine("Cell has a formula");
                        Form1.Step("Cell has a formula");
                    }
                    else
                    {
                        try
                        {
                            //Cell has a value
                            Parts.Insert(i, Convert.ToDouble(temp));

                            OutFile.WriteLine("Cell has a number");
                            Form1.Step("Cell has a number");
                        }
                        catch
                        {
                            OutFile.WriteLine("Cell has a string");
                            Form1.Step("Cell has a string");
                            //ERROR: Cell has a string
                            return Parts;
                        }
                    }
                }
            }
            
            return Parts;
        }
Example #26
0
 public override void Filter(ArrayList list)
 {
     if (list.Count > this.m_Limit)
         list.RemoveRange(this.m_Limit, list.Count - this.m_Limit);
 }
        private ContentSourceInfo[] GetSidebarContentSources(int maxSources)
        {
            ArrayList sidebarContentSources = new ArrayList();
            if ( maxSources <= ContentSourceManager.BuiltInInsertableContentSources.Length )
            {
                // clip the list of standard spources if necessary
                for( int i=0; i<maxSources; i++ )
                    sidebarContentSources.Add(ContentSourceManager.BuiltInInsertableContentSources[i]);
            }
            else
            {
                // add all of the standard sources
                sidebarContentSources.AddRange(ContentSourceManager.BuiltInInsertableContentSources);

                // if we have to clip the list of plugin sources then do it based
                // on which sources have been most recently used
                int sourcesLeft = maxSources - sidebarContentSources.Count ;
                if ( sourcesLeft < ContentSourceManager.PluginInsertableContentSources.Length )
                {
                    // get the list that we actually want to include
                    ArrayList filteredPluginContentSources = new ArrayList(ContentSourceManager.PluginInsertableContentSources);
                    filteredPluginContentSources.Sort(new ContentSourceInfo.LastUseComparer());
                    filteredPluginContentSources.RemoveRange(sourcesLeft, filteredPluginContentSources.Count-sourcesLeft);

                    // iterate through the parent list and add the ones that made the cut
                    foreach (ContentSourceInfo contentSourceInfo in ContentSourceManager.PluginInsertableContentSources)
                        if ( filteredPluginContentSources.Contains(contentSourceInfo))
                            sidebarContentSources.Add(contentSourceInfo);
                }
                else
                {
                    sidebarContentSources.AddRange(ContentSourceManager.PluginInsertableContentSources);
                }
            }

            return sidebarContentSources.ToArray(typeof(ContentSourceInfo)) as ContentSourceInfo[] ;
        }
Example #28
0
		public void TestRemoveRange ()
		{
			{
				bool errorThrown = false;
				try {
					ArrayList al1 =
						ArrayList.FixedSize (new ArrayList (3));
					al1.RemoveRange (0, 1);
				} catch (NotSupportedException) {
					errorThrown = true;
				}
				Assert.IsTrue (errorThrown, "removerange from fixed size error not thrown");
			}
			{
				bool errorThrown = false;
				try {
					ArrayList al1 =
						ArrayList.ReadOnly (new ArrayList (3));
					al1.RemoveRange (0, 1);
				} catch (NotSupportedException) {
					errorThrown = true;
				}
				Assert.IsTrue (errorThrown, "removerange from read only error not thrown");
			}
			{
				bool errorThrown = false;
				try {
					ArrayList al1 = new ArrayList (3);
					al1.RemoveRange (-1, 1);
				} catch (ArgumentOutOfRangeException) {
					errorThrown = true;
				}
				Assert.IsTrue (errorThrown, "removerange at negative index error not thrown");
			}
			{
				bool errorThrown = false;
				try {
					ArrayList al1 = new ArrayList (3);
					al1.RemoveRange (0, -1);
				} catch (ArgumentOutOfRangeException) {
					errorThrown = true;
				}
				Assert.IsTrue (errorThrown, "removerange at negative index error not thrown");
			}
			{
				bool errorThrown = false;
				try {
					ArrayList al1 = new ArrayList (3);
					al1.RemoveRange (2, 3);
				} catch (ArgumentException) {
					errorThrown = true;
				}
				Assert.IsTrue (errorThrown, "removerange at bad range error not thrown");
			}
			{
				char [] c = { 'a', 'b', 'c' };
				ArrayList a = new ArrayList (c);
				a.RemoveRange (1, 2);
				Assert.AreEqual (1, a.Count, "should be changed");
				Assert.AreEqual ('a', a [0], "should have shifted");
			}
		}
Example #29
0
        // GetValues
        // Routine Description:
        //     This method takes a header name and returns a string array representing
        //     the individual values for that headers. For example, if the headers
        //     contained the line Accept: text/plain, text/html then
        //     GetValues("Accept") would return an array of two strings: "text/plain"
        //     and "text/html".
        // Arguments:
        //     header      - Name of the header.
        // Return Value:
        //     string[] - array of parsed string objects

        /// <devdoc>
        ///    <para>
        ///       Gets an array of header values stored in a
        ///       header.
        ///    </para>
        /// </devdoc>
        public override string[] GetValues(string header) {
            // This method doesn't work with common headers.  Dump common headers into the pool.
            NormalizeCommonHeaders();

            // First get the information about the header and the values for
            // the header.
            HeaderInfo Info = HInfo[header];
            string[] Values = InnerCollection.GetValues(header);
            // If we have no information about the header or it doesn't allow
            // multiple values, just return the values.
            if (Info == null || Values == null || !Info.AllowMultiValues) {
                return Values;
            }
            // Here we have a multi value header. We need to go through
            // each entry in the multi values array, and if an entry itself
            // has multiple values we'll need to combine those in.
            //
            // We do some optimazation here, where we try not to copy the
            // values unless there really is one that have multiple values.
            string[] TempValues;
            ArrayList ValueList = null;
            int i;
            for (i = 0; i < Values.Length; i++) {
                // Parse this value header.
                TempValues = Info.Parser(Values[i]);
                // If we don't have an array list yet, see if this
                // value has multiple values.
                if (ValueList == null) {
                    // See if it has multiple values.
                    if (TempValues.Length > 1) {
                        // It does, so we need to create an array list that
                        // represents the Values, then trim out this one and
                        // the ones after it that haven't been parsed yet.
                        ValueList = new ArrayList(Values);
                        ValueList.RemoveRange(i, Values.Length - i);
                        ValueList.AddRange(TempValues);
                    }
                }
                else {
                    // We already have an ArrayList, so just add the values.
                    ValueList.AddRange(TempValues);
                }
            }
            // See if we have an ArrayList. If we don't, just return the values.
            // Otherwise convert the ArrayList to a string array and return that.
            if (ValueList != null) {
                string[] ReturnArray = new string[ValueList.Count];
                ValueList.CopyTo(ReturnArray);
                return ReturnArray;
            }
            return Values;
        }
Example #30
0
		public void RemoveRange_IndexOverflow ()
		{
			ArrayList al = new ArrayList ();
			al.Add (this);
			al.RemoveRange (Int32.MaxValue, 1);
		}