当前位置: 首页>>代码示例>>C#>>正文


C# ArrayList.add方法代码示例

本文整理汇总了C#中ArrayList.add方法的典型用法代码示例。如果您正苦于以下问题:C# ArrayList.add方法的具体用法?C# ArrayList.add怎么用?C# ArrayList.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ArrayList的用法示例。


在下文中一共展示了ArrayList.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

 public static void Main()
 {
     ArrayList list = new ArrayList();
     list.add(new MyClass(10,"sdg"));
     list.add(new MyClass(13,"uy,k"));
     list.add(new MyClass(14,"tho"));
     list.sort();
 }
开发者ID:rags,项目名称:playground,代码行数:8,代码来源:SearchList.cs

示例2: test

	public static string test() {
		var list = new ArrayList<string>();
		list.add("a");
		list.add("b");
		list.add("c");
		
		var sb = new StringBuilder();
		foreach (var s in list) {
			sb.append(s);
		}
		
		return sb.toString();
	}
开发者ID:nagyistoce,项目名称:cnatural-language,代码行数:13,代码来源:ForeachList.stab.cs

示例3: Main

        static void Main(string[] args)
        {
            Vehicle vCar = new Car("Diesel","Fiat","600");
			Vehicle vMoto = new Motorbike("1500","Ducatti","1500");
			Vehicle vBoat = new Boat("10000","Vasque","3",3);
			
			ArrayList Vehicles = new ArrayList();
			Vehicles.add(vCar);
			Vehicles.add(vMoto);
			Vehicles.add(vBoat);
			
			list(Vehicles);
			
		}
开发者ID:pierVCS,项目名称:TestOne,代码行数:14,代码来源:vehicles.cs

示例4: Main

    static void Main()
    {
        /*int firstNum = int.Parse(Console.ReadLine());
        float secondNum = float.Parse(Console.ReadLine());
        float thirdNum = float.Parse(Console.ReadLine());

        string hexOutput = String.Format("{0:X}", firstNum);
        string formattedText = "{0, -1} | {1, 10} | {2, 10:0.00} | {3, -1:0.000} |";

        if (firstNum >= 0 && firstNum <= 500)
        {
            Console.WriteLine(formattedText, hexOutput, Convert.ToString(firstNum, 2), secondNum, thirdNum);
        }
        else
        {
            Console.WriteLine("First number should be >= 0 and <= 500!");
            return;
        }*/
        int[] test = { 10212, 10202, 11000, 11000, 11010 };
        ArrayList<Integer> test2 = new ArrayList<Integer>();


        for (int i = test.length - 1; i >= 0; i--)
        {
            int temp = test[i];
            while (temp > 0)
            {
                test2.add(0, temp % 10);  //place low order digit in array
                temp = temp / 10;        //remove low order digit from temp;
            }
        }
    }
开发者ID:dgrigorov,项目名称:TelerikAcademy,代码行数:32,代码来源:05.FormattingNumbers.cs

示例5: split

 public String[] split(CharSequence input, int limit) {
     int index = 0;
     boolean matchLimited = limit > 0;
     ArrayList<String> matchList = new ArrayList<String>();
     Matcher m = matcher(input);
     // Add segments before each match found
     while(m.find()) {
         if (!matchLimited || matchList.size() < limit - 1) {
             String match = input.subSequence(index, m.start()).toString();
             matchList.add(match);
             index = m.end();
         } else if (matchList.size() == limit - 1) { // last one
             String match = input.subSequence(index,
                                              input.length()).toString();
             matchList.add(match);
             index = m.end();
         }
     }
     // If no match was found, return this
     if (index == 0)
         return new String[] {input.toString()};
     // Add remaining segment
     if (!matchLimited || matchList.size() < limit)
         matchList.add(input.subSequence(index, input.length()).toString());
     // Construct result
     int resultSize = matchList.size();
     if (limit == 0)
         while (resultSize > 0 && matchList.get(resultSize-1).equals(""))
             resultSize--;
     String[] result = new String[resultSize];
     return matchList.subList(0, resultSize).toArray(result);
 }
开发者ID:jason-persson,项目名称:LibPhoneNumberPortable,代码行数:32,代码来源:Pattern.cs

示例6: ParameterList

	// TODO checks
	public ParameterList(InputPacket packet)   {
		super(0);
		// array lists in which store parameters
		ArrayList parameters = new ArrayList();
		
		bool stop = false;
		do {
			// at least 4 bytes for length and type
			if (packet.getCursorPosition() + 4 <= packet.getLength()) {
				short parameterId = packet.read_short();
				short length = packet.read_short();
				byte[] p = new byte[length];
				if (parameterId != PID_SENTINEL) {
					for (int i=0; i<length; i++) {
						p[i] = packet.read_octet();
					}
					parameters.add(new Parameter(parameterId,length,p));
				}
				else {
					stop = true;
				}
			}
			else {
				throw  new MalformedSubmessageElementException("ParameterList too short");
			}
		} while (!stop);
		
		value = new Parameter[parameters.size()];
		parameters.toArray(value);
	}	
开发者ID:Egipto87,项目名称:DOOP.ec,代码行数:31,代码来源:ParameterList.cs

示例7: EnumerableTest

        public void EnumerableTest()
        {
            const string expectedStringBase = "str1ng";

            var list = new ArrayList<String>();
            list.add(expectedStringBase + "0");
            list.add(expectedStringBase + "1");
            list.add(expectedStringBase + "2");

            var currentIndex = -1;
            foreach (var item in list)
            {
                currentIndex++;
                Assert.AreEqual(expectedStringBase + currentIndex, (string)item);
            }

            Assert.AreEqual(2, currentIndex);
        }
开发者ID:bcrusu,项目名称:jvm4csharp,代码行数:18,代码来源:IterableTests.cs

示例8: addTest

 //$goals 18
 //$benchmark
 public void addTest(ArrayList arrayList, Object o)
 {
     if (arrayList != null) {
         {/*$goal 0 reachable*/}
         boolean ret_val = arrayList.add(o);
     } else {
         {/*$goal 1 reachable*/}
     }
 }
开发者ID:taoxiease,项目名称:roops,代码行数:11,代码来源:ArrayList.cs

示例9: testGetPositions

	public void testGetPositions() {
		List<XYLocation> expected = new ArrayList<XYLocation>();
		expected.add(new XYLocation(0, 2));
		expected.add(new XYLocation(1, 1));
		expected.add(new XYLocation(2, 2));
		expected.add(new XYLocation(2, 1));
		expected.add(new XYLocation(0, 1));
		expected.add(new XYLocation(0, 0));
		expected.add(new XYLocation(1, 0));
		expected.add(new XYLocation(2, 0));
		expected.add(new XYLocation(1, 2));

		List<XYLocation> actual = board.getPositions();
		Assert.assertEquals(expected, actual);
	}
开发者ID:PaulMineau,项目名称:AIMA.Net,代码行数:15,代码来源:EightPuzzleBoardTest.cs

示例10: testSuccessors

	public void testSuccessors() {
		ArrayList<String> locations = new ArrayList<String>();

		// A
		locations.clear();
		locations.add("B");
		locations.add("C");
		for (Action a : af.actions("A")) {
			Assert.assertTrue(locations.contains(((MoveToAction) a)
					.getToLocation()));
			Assert.assertTrue(locations.contains(rf.result("A", a)));
		}

		// B
		locations.clear();
		locations.add("A");
		locations.add("C");
		locations.add("E");
		for (Action a : af.actions("B")) {
			Assert.assertTrue(locations.contains(((MoveToAction) a)
					.getToLocation()));
			Assert.assertTrue(locations.contains(rf.result("B", a)));
		}

		// C
		locations.clear();
		locations.add("A");
		locations.add("B");
		locations.add("D");
		for (Action a : af.actions("C")) {
			Assert.assertTrue(locations.contains(((MoveToAction) a)
					.getToLocation()));
			Assert.assertTrue(locations.contains(rf.result("C", a)));
		}

		// D
		locations.clear();
		locations.add("C");
		for (Action a : af.actions("D")) {
			Assert.assertTrue(locations.contains(((MoveToAction) a)
					.getToLocation()));
			Assert.assertTrue(locations.contains(rf.result("D", a)));
		}
		// E
		locations.clear();
		Assert.assertTrue(0 == af.actions("E").size());
	}
开发者ID:PaulMineau,项目名称:AIMA.Net,代码行数:47,代码来源:MapFunctionFactoryTest.cs

示例11: testSetBoard

	public void testSetBoard() {
		List<XYLocation> passedIn = new ArrayList<XYLocation>();
		passedIn.add(new XYLocation(1, 1));
		passedIn.add(new XYLocation(0, 2));
		passedIn.add(new XYLocation(2, 2));
		passedIn.add(new XYLocation(2, 1));
		passedIn.add(new XYLocation(0, 1));
		passedIn.add(new XYLocation(0, 0));
		passedIn.add(new XYLocation(1, 0));
		passedIn.add(new XYLocation(2, 0));
		passedIn.add(new XYLocation(1, 2));
		board.setBoard(passedIn);
		Assert.assertEquals(new XYLocation(1, 1), board.getLocationOf(0));
		Assert.assertEquals(new XYLocation(0, 2), board.getLocationOf(1));
	}
开发者ID:PaulMineau,项目名称:AIMA.Net,代码行数:15,代码来源:EightPuzzleBoardTest.cs

示例12: testLocationsLinkedTo

	public void testLocationsLinkedTo() {
		ArrayList<String> locations = new ArrayList<String>();
		List<String> linkedTo;

		linkedTo = aMap.getLocationsLinkedTo("A");
		locations.clear();
		locations.add("B");
		locations.add("C");
		Assert.assertTrue(locations.containsAll(linkedTo)
				&& linkedTo.size() == 2);

		linkedTo = aMap.getLocationsLinkedTo("B");
		locations.clear();
		locations.add("A");
		locations.add("C");
		locations.add("E");
		Assert.assertTrue(locations.containsAll(linkedTo)
				&& linkedTo.size() == 3);

		linkedTo = aMap.getLocationsLinkedTo("C");
		locations.clear();
		locations.add("A");
		locations.add("B");
		locations.add("D");
		Assert.assertTrue(locations.containsAll(linkedTo)
				&& linkedTo.size() == 3);

		linkedTo = aMap.getLocationsLinkedTo("D");
		locations.clear();
		locations.add("C");
		Assert.assertTrue(locations.containsAll(linkedTo)
				&& linkedTo.size() == 1);

		linkedTo = aMap.getLocationsLinkedTo("E");
		Assert.assertTrue(linkedTo.size() == 0);
	}
开发者ID:PaulMineau,项目名称:AIMA.Net,代码行数:36,代码来源:MapTest.cs

示例13: getItems

		/**
     * Returns an unmodifiable copy of the {@link Item Items} in the roster packet.
     *
     * @return an unmodifable copy of the {@link Item Items} in the roster packet.
     */
		public Collection<Item> getItems() {
			Collection<Item> items = new ArrayList<Item>();
            XElement query = element.Element(XName.Get("query", "jabber:iq:roster"));
			if (query != null) {
				for (Iterator<XElement> i=query.elementIterator("item"); i.hasNext(); ) {
					Element item = i.next();
					String jid = item.attributeValue("jid");
					String name = item.attributeValue("name");
					String ask = item.attributeValue("ask");
					String subscription = item.attributeValue("subscription");
					Collection<String> groups = new ArrayList<String>();
					for (Iterator<Element> j=item.elementIterator("group"); j.hasNext(); ) {
						Element group = j.next();
						groups.add(group.getText().trim());
					}
					Ask askStatus = ask == null ? null : Ask.valueOf(ask);
					Subscription subStatus = subscription == null ?
						null : Subscription.valueOf(subscription);
					items.add(new Item(new JID(jid), name, askStatus, subStatus, groups));
				}
			}
			return Collections.unmodifiableCollection(items);
		}
开发者ID:kashifsoofi,项目名称:Openfire.Net,代码行数:28,代码来源:Roster.cs

示例14: Evaluate

        //Function to cross all informations added to this face and evaluate the best values
        public void Evaluate()
        {
            //Evaluate mouth
            evaluatedMouth = new Rect(0, 0, 0, 0);
            //Random randomizer = new Random();

            //evaluatedMouth = mouths[randomizer.Next(0, mouths.Count - 1)];

            //must work a few on the mouth to choose the best one and proceed to histogram check for try to determinate skin color, eye color, hair color etc..

            foreach (Rect mouth in mouths)
            {
                if (mouth.y < face.y + face.height / 2)
                    continue;

                if (evaluatedMouth.width > mouth.width)
                    continue;

                evaluatedMouth = mouth;
            }

            //Evaluate eyes
            evaluatedEyes = new ArrayList<Rect>();
            ArrayList<Rect> rightCandidates = new ArrayList<Rect>();
            ArrayList<Rect> leftCandidates = new ArrayList<Rect>();

            foreach (Rect eye in eyes)
            {
                //Ensure the eyes are in the upper half of the img region
                if (eye.y + eye.height / 2 > face.y + face.height / 2)
                    continue;

                if (eye.x + eye.width / 2 < face.x + face.width / 2)
                    rightCandidates.add(eye);
                else
                    leftCandidates.add(eye);
            }

            //get centers for each side weighted by their areas
            int totalAreas = 0;
            int totalX = 0;
            int totalY = 0;

            if (rightCandidates.size() > 0)
            {
                foreach (Rect eye in rightCandidates)
                {
                    int eyeArea = eye.width * eye.height;
                    totalAreas += eyeArea;

                    totalX += (eye.x + eye.width / 2) * eyeArea;
                    totalY += (eye.y + eye.height / 2) * eyeArea;
                }

                Point rightPoint = new Point(totalX / totalAreas, totalY / totalAreas);

                int rightEyeSide = (int)Math.Sqrt((double)totalAreas / (double)rightCandidates.size());

                Rect rightEye = new Rect(
                    rightPoint.x - rightEyeSide / 2,
                    rightPoint.y - rightEyeSide / 2,
                    rightEyeSide,
                    rightEyeSide);

                //rightEye.Offset(-rightEye.Width / 2, -rightEye.Height / 2);

                evaluatedEyes.add(rightEye);
            }

            if (leftCandidates.size() > 0)
            {
                totalAreas = 0;
                totalX = 0;
                totalY = 0;

                foreach (Rect eye in leftCandidates)
                {
                    int eyeArea = eye.width * eye.height;
                    totalAreas += eyeArea;

                    totalX += (eye.x + eye.width / 2) * eyeArea;
                    totalY += (eye.y + eye.height / 2) * eyeArea;
                }

                Point leftPoint = new Point(totalX / totalAreas, totalY / totalAreas);

                int leftEyeSide = (int)Math.Sqrt((double)totalAreas / (double)leftCandidates.size());

                Rect leftEye = new Rect(
                    leftPoint.x - leftEyeSide / 2,
                    leftPoint.y - leftEyeSide / 2,
                    leftEyeSide,
                    leftEyeSide);

                //leftEye.Offset(-leftEye.Width / 2, -leftEye.Height / 2);

                evaluatedEyes.add(leftEye);
            }

//.........这里部分代码省略.........
开发者ID:lucasolivier,项目名称:ImagineAlpha,代码行数:101,代码来源:PersonFace.cs

示例15: testRandomGeneration

	public void testRandomGeneration() {
		ArrayList<String> locations = new ArrayList<String>();
		locations.add("A");
		locations.add("B");
		locations.add("C");
		locations.add("D");
		locations.add("E");

		for (int i = 0; i < locations.size(); i++) {
			Assert.assertTrue(locations.contains(aMap
					.randomlyGenerateDestination()));
		}
	}
开发者ID:PaulMineau,项目名称:AIMA.Net,代码行数:13,代码来源:MapTest.cs


注:本文中的ArrayList.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。