Remove() public method

public Remove ( Object obj ) : void
obj Object
return void
        public bool Matches(object one, object two)
        {
            var expected = new ArrayList(one.As<ICollection>());
            var actual = new ArrayList(two.As<ICollection>());

            foreach (object o in actual.ToArray())
            {
                if (expected.Contains(o))
                {
                    actual.Remove(o);
                    expected.Remove(o);
                }
            }

            foreach (object o in expected.ToArray())
            {
                if (actual.Contains(o))
                {
                    actual.Remove(o);
                    expected.Remove(o);
                }
            }

            return actual.Count == 0 && expected.Count == 0;
        }
Example #2
0
		public static void CleanThread(ArrayList WorkThreadPool, int Timeout)
		{
			ThreadInfo CurrentThreadInfo;

			for (int index = 0; index < WorkThreadPool.Count; index++)
			{
				CurrentThreadInfo = (ThreadInfo)WorkThreadPool[index];

				// 清除已经结束的线程,不再保存信息
				if (CurrentThreadInfo.ThreadName.ThreadState == ThreadState.Stopped)
				{
					WorkThreadPool.Remove(CurrentThreadInfo);
				}

				// 清除超时没有连接上的线程,强行杀掉,并从池中清除信息
				// 超时按照毫秒计算
				else if (CurrentThreadInfo.LiveTime > Timeout)
				{
					CurrentThreadInfo.ThreadName.Abort();

					if (CurrentThreadInfo.ThreadName.Join(2000))
					{
						WorkThreadPool.Remove(CurrentThreadInfo);
					}
				}

				// 每个活动线程的已生存了的时间增加500毫秒
				else
				{
					CurrentThreadInfo.LiveTime += 500;
				}
			}
		}
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 crash(Fish fish, Form1 form, ArrayList fishList)
        {
            collision = aquaticAnimal.Bounds.IntersectsWith(fish.aquaticAnimal.Bounds);

             if (collision==true)
             {
                  if ((aquaticAnimal.ImageLocation.Equals(@"Resources\tiburon adulto.png") || aquaticAnimal.ImageLocation.Equals(@"Resources\tiburon hembra.png")) && (fish.aquaticAnimal.ImageLocation.Equals(@"Resources\Dorys.png") || fish.aquaticAnimal.ImageLocation.Equals(@"Resources\Nemo.png")))
                  {
                      fishList.Remove(fish);
                      fish.aquaticAnimal.Hide();
                  }
                  else if ((aquaticAnimal.ImageLocation.Equals(@"Resources\Dorys.png") || aquaticAnimal.ImageLocation.Equals(@"Resources\Nemo.png")) && (fish.aquaticAnimal.ImageLocation.Equals(@"Resources\tiburon adulto.png") || fish.aquaticAnimal.ImageLocation.Equals(@"Resources\tiburon hembra.png")))
                  {
                      fishList.Remove(aquaticAnimal);
                      aquaticAnimal.Hide();
                  }
                  else if ((aquaticAnimal.ImageLocation.Equals(@"Resources\Nemo.png") && fish.aquaticAnimal.ImageLocation.Equals(@"Resources\Nemo.png")))
                  {
                      fishList.Remove(fish);
                      aquaticAnimal.Hide();
                  }
                 else if ((aquaticAnimal.ImageLocation.Equals(@"Resources\tiburon adulto.png") && fish.aquaticAnimal.ImageLocation.Equals(@"Resources\tiburon adulto.png")))
                  {
                      fishList.Remove(aquaticAnimal);
                      aquaticAnimal.Hide();
                  }

             }
        }
        static void Main(string[] args)
        {
            Microsoft.Win32.SafeHandles.SafeFileHandle h;
            string dEntry = "\\";
            ArrayList entries = new ArrayList();
            entries.Add(dEntry);
            while (entries.Count != 0)
            {
                foreach (String entry in entries)
                {
                    var attr = new Win.OBJECT_ATTRIBUTES(entry, 0);
                    var st = Win.NtOpenDirectoryObject(out h, 1, ref attr);
                    if (st < 0)
                    {
                        h.Dispose();
                        entries.Remove(entry);
                        break;
                    }

                    var bufsz = 1024;
                    var buf = Marshal.AllocHGlobal(bufsz);
                    uint context = 0, len;
                    while (true)
                    {
                        st = Win.NtQueryDirectoryObject(h, buf, bufsz, true, context == 0, ref context, out len);
                        if (st < 0)
                        {
                            entries.Remove(entry);
                            Marshal.FreeHGlobal(buf);
                            h.Dispose();
                            break;
                        }
                        var odi = (Win.OBJECT_DIRECTORY_INFORMATION)
                          Marshal.PtrToStructure(buf, typeof(Win.OBJECT_DIRECTORY_INFORMATION));
                        if (Convert.ToString(odi.TypeName) == "Mutant")
                        {
                            Console.WriteLine("0x{0:X2}:{1,-25}{2}", context, odi.TypeName, odi.Name);
                            parseMutex(Convert.ToString(odi.Name));
                        }
                        if (Convert.ToString(odi.TypeName) == "Directory")
                        {
                            if (entry == "\\")
                            {
                                entries.Add(entry + Convert.ToString(odi.Name));
                            }
                            else
                            {
                                entries.Add(entry + "\\" + Convert.ToString(odi.Name));
                            }
                        }
                    }
                    break;
                }
            }
        }
Example #6
0
        private static void play()
        {
            Console.WriteLine("Would you prefer what is behind door number 1, 2, or 3?");
            int min = 1;
            int max = 4;

            // Load the random numbers
            ArrayList availableNumbers = new ArrayList();
            for (int i = min; i < max; i++)
                availableNumbers.Add(i);

            // Assign the first number to the car's door number
            int carValue = RandomNumber(min, max);
            availableNumbers.Remove(carValue);
            int boatValue = carValue;
            int catValue;
            string message;

            // Randomly search for a value for the boat's door number
            while (!availableNumbers.Contains(boatValue))
                boatValue = RandomNumber(min, max);
            availableNumbers.Remove(boatValue);

            // Assign the cat value the remaining number
            catValue = (int)availableNumbers[0];

            // DEBUG
            //Console.WriteLine(String.Format("CarValue: {0} BoatValue: {1} CatValue: {2}",carValue,boatValue,catValue));

            // Read the user input
            int userValue = readNumber(min, max);

            // The 'CatValue' variable now only holds debug purposes, due to sufficient validation on the integer input
            if (userValue == carValue)
                message = "You won a new car!";
            else if (userValue == boatValue)
                message = "You won a new boat!";
            else
                message = "You won a new cat!";

            Console.WriteLine(message);

            Console.WriteLine("Do you want to play again? [Y/N]");
            TextInfo ti = new CultureInfo("en-US", false).TextInfo;
            if (String.Compare(ti.ToLower(readString()), "y") == 0)
            {
                // Repeat
                Console.WriteLine("");
                play();
            }
            else
                // Cleanly exit
                Environment.Exit(-1);
        }
        static void Main()
        {
            Console.Write("List 1: ");
            string[] names1 = Console.ReadLine().Split(' ');
            Console.Write("List 2: ");
            string[] names2 = Console.ReadLine().Split(' ');

            ArrayList list1 = new ArrayList(names1);
            ArrayList list2 = new ArrayList(names2);

            for (int i = 0; i < list2.Count; i++)
            {
                while (list1.Contains(list2[i]))
                {
                    list1.Remove(list2[i]);
                }
            }

            for (int i = 0; i < list1.Count; i++)
            {
                Console.Write(list1[i]);
                if (i < list1.Count - 1)
                {
                    Console.Write(" ");
                }
            }

            Console.WriteLine();
        }
Example #8
0
        private void button3_Click(object sender, EventArgs e)
        {
            ArrayList arr = new ArrayList();
            arr.Add(10);
            arr.Add(20); //To add a new element at the end of collection
            arr.Add(30);
            arr.Add(40);
            arr.Add(50);
            arr.Add(60);
            arr.Add(70);
            arr.Add(80);
            arr.Add(90);
            arr[3] = 400; //To overwrite the value
            MessageBox.Show(arr.Capacity.ToString());
            arr.Insert(3, 1000);//insert in the middle
            //shift the other elements =>index,value
            foreach (object obj in arr)
            {
                listBox3.Items.Add(obj.ToString());
            }

            arr[12] = 10; //Runtime error

            arr.Remove(10);  //remove 10 <=value
            arr.RemoveAt(1); //remove element at index 1 <=index
        }
        public void PrintWords()
        {
            var word = _dictionary.GetNextWord(_letterCount);
            var i = 1;
            while (word != null)
            {
                var containsValidLetters = true;
                var tmpAlphabet = new ArrayList(_alphabet);

                foreach (var item in word)
                {
                    if (tmpAlphabet.Contains(item))
                    {
                        // такая буква есть в слове, удаляем её из алфавита, 
                        // чтобы не использовать дважды
                        tmpAlphabet.Remove(item);
                    }
                    else
                    {
                        // DEBUG
                        //Console.WriteLine("***" + word + "***");
                        // END DEBUG
                        containsValidLetters = false;
                        break;
                    }
                }

                if (containsValidLetters)
                {
                    Console.WriteLine("{0} {1}", i++, word);
                }

                word = _dictionary.GetNextWord(_letterCount);
            }
        }
        /// <summary>
        /// Remove owner window from hook tracing
        /// </summary>
        /// <param name="owner_window">owner window</param>
        static public void RemoveOwnerWindow(IntPtr owner_window)
        {
            lock (static_lock_variable)
            {
                try
                {
                    ICollection a = (ICollection)owner_windows.Clone();
                    ArrayList al = new ArrayList((ICollection)a);
                    al.Remove(owner_window);
                    owner_windows = (IntPtr[])al.ToArray(typeof(IntPtr));

                    owner_window_logs.Remove(owner_window);

                    if (owner_windows.Length < 1 && hook_id != IntPtr.Zero)
                    {
                        Win32.UnhookWindowsHookEx(hook_id);
                        hook_id = IntPtr.Zero;
                    }
                }
                catch (Exception e)
                {
                    Log.Main.Exit(e);
                }
            }
        }
Example #11
0
        private Boolean is_anagram(string word1, string word2)
        {
            int i;
            ArrayList array_word1 = new ArrayList(Convert.ToInt32(word1.Length));
            ArrayList array_word2 = new ArrayList(Convert.ToInt32(word2.Length));
            word1 = word1.ToLower();
            word2 = word2.ToLower();

            if (word1.Length != word2.Length)
                return false;

            for (i = 0; i < word1.Length; i++)
                array_word1.Add(word1[i].ToString());

            for (i = 0; i < word2.Length; i++)
                array_word2.Add(word2[i].ToString());

            foreach (string val in array_word1)
            {
                if (array_word2.Contains(val))
                    array_word2.Remove(val);
            }

            if (array_word2.Count == 0)
                return true;
            else
                return false;
        }
        public void Verify(ParameterList actualList)
        {
            var expectedKeys = new ArrayList(AllKeys);
            var actualKeys = new ArrayList(actualList.AllKeys);
            var unionKeys = new ArrayList();

            var keys = (string[]) actualKeys.ToArray(typeof (string));

            foreach (string key in keys)
            {
                if (expectedKeys.Contains(key))
                {
                    unionKeys.Add(key);
                    expectedKeys.Remove(key);
                    actualKeys.Remove(key);
                }
            }

            var failureCondition = new ParameterValidationFailureException();

            checkForWrongParameterValues(unionKeys, actualList, failureCondition);
            checkForMissingParameters(expectedKeys, failureCondition);
            checkForUnExpectedParameters(actualList, actualKeys, failureCondition);

            failureCondition.ThrowIfExceptions();
        }
Example #13
0
 public List(Type type)
 {
     _myType = type;
     _list = new ArrayList();
     _list.Remove(0);
     _index = 0;
 }
Example #14
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 #15
0
        public static void Main(string[] args)
        {
            ArrayList list = new ArrayList();
            Dog[] mas = new Dog[1];

            Dog dog1 = new Dog("no name 0",12,0.1f);

            list.Add(dog1);
            list.Add(new chicken("no name 1",2,0.4f));
            list.Add(new Dog("no name 2",1,0.1f));
            mas[0] = dog1;

            foreach(Dog d in list)
            {
                    list.Remove(d);
                    Console.WriteLine("{0} - убит",d.name);
                    break;
            }

            cow[] muMas = new cow[3];
            muMas[0] = new cow("no name 3",13,0.1f);
            muMas[1] = new cow("no name 4",3,0.2f);
            muMas[2] = new cow("no name 5",11,0.4f);

            list.Add(muMas);

            foreach(object d in list)
            {
                Console.WriteLine(d.ToString());
                if(d.Equals(muMas))
                    foreach(cow c in muMas)
                        Console.WriteLine(c.ToString()+"; индексатор "+c[0]);

            }
        }
        static void Main(string[] args)
        {
            ArrayList a = new ArrayList();
            a.Add(123);
            a.Add("BARD");
            a.Add(34.689);
            a.Insert(2, 'A');
            a.Remove(123);
            a.RemoveAt(2);
            foreach (Object o in a)
            {
                Console.WriteLine(o.ToString());
            }

            //Student s = new Student();
            //s.GetData();
            //a.Add(s);
            //foreach (Object o in a)
            //{
            //    if (o.GetType().ToString() == "ArrayListSample.Student")
            //    {
            //        Student s1 = (Student)o;
            //        s1.ShowData();
            //    }
            //}
            //Console.WriteLine("No of elements are:" +a.Count);

            Console.Read();
        }
Example #17
0
        /// <summary>
        /// Moves the selected items from the origin to the destination.
        /// </summary>
        /// <param name="origin">The origin.</param>
        /// <param name="destination">The destination.</param>
        private static void moveItem(ListBox origin, ListBox destination)
        {
            //Create ArrayList of current items
            var originList = new ArrayList(origin.Items);

            //Create ArrayList of destination items
            var destinationList = new ArrayList(destination.Items);

            //Add selected items from origin listbox to destination list
            foreach (ListBoxItem item in origin.SelectedItems)
            {
                destinationList.Add(item);
            }

            //remove the selected items from the origin list
            foreach (var item in origin.SelectedItems)
            {
                originList.Remove(item);
            }

            //Comparer for sorting
            var comparer = new ListBoxItem();

            //Clear and repopulate origin Listbox sorted
            originList.Sort(comparer);
            origin.Items.Clear();
            origin.Items.AddRange(originList.ToArray());

            //Clear and repopulate destination Listbox sorted
            destinationList.Sort(comparer);
            destination.Items.Clear();
            destination.Items.AddRange(destinationList.ToArray());
        }
        public ActionResult EditUser(string id, bool approved)
        {
            //Is a list of all the user roles
            ArrayList removeRoleList = new ArrayList(Roles.GetAllRoles());

            //We are requesting the form variables directly from the form
            foreach (string key in Request.Form.Keys)
            {
                if (key.StartsWith("role."))
                {
                    String userRole = key.Substring(5, key.Length - 5);
                    removeRoleList.Remove(userRole);
                    if (!Roles.IsUserInRole(id, userRole))
                    {
                        Roles.AddUserToRole(id, userRole);
                    }
                }
            }

            foreach (string removeRole in removeRoleList)
                Roles.RemoveUserFromRole(id, removeRole);

            MembershipUser membershipUser = Membership.GetUser(id);
            membershipUser.IsApproved = approved;
            Membership.UpdateUser(membershipUser);

            TempData["SuccessMessage"] = "User Information has been updated";
            ViewData["roles"] = (String[])Roles.GetAllRoles();
            ViewData["PageTitle"] = "Edit " + id;
            return View(membershipUser);
        }
        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 #20
0
        static void Main(string[] args)
        {
            IList list1 = new ArrayList();
            list1.Add("Hello, ");
            list1.Add("my ");
            list1.Add("dear ");
            list1.Add("old ");
            list1.Add("friend! ");

            IList list2 = new ArrayList();
            list2.Add("my ");
            list2.Add("dear ");
            list2.Add("old ");

            foreach (var value in list2)
            {
                while (list1.Contains(value))
                {
                    list1.Remove(value);
                }
            }

            foreach (var v in list1)
            {
                Console.Write(v);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //1. create empty ArrayList
            ArrayList al = new ArrayList();

            //2. add element into array list
            al.Add("Dog");
            al.Add("Cat");
            al.Add("Elephant");
            al.Add("Lion");
            al.Add("Cat");
            al.Add("Platypus");

            //3. bind above arrayList to first list box
            lbOriginal.DataSource = al;
            lbOriginal.DataBind();

            //4. change (insert -> remove ->remove)
            al.Insert(1, "Chicken~~~");
            al.Remove("Cat");
            al.RemoveAt(0);

            //5. bind the result into second list box
            lbChanged.DataSource = al;
            lbChanged.DataBind();
        }
Example #22
0
        public void NachrichtAnAlle(ArrayList b, string Nachricht)
        {
            //dringend bearbeiten

            while (true)
            {
                try
                {
                    foreach (Server.extended y in b)
                    {
                        try
                        {
                            NetworkStream clientStream = y.tcp.GetStream();
                            ASCIIEncoding encoder = new ASCIIEncoding();
                            byte[] buffer = encoder.GetBytes(Nachricht);

                            clientStream.Write(buffer, 0, buffer.Length);
                            clientStream.Flush();

                        }
                        catch
                        {
                            b.Remove(y);
                        }

                    }
                    break;
                }
                catch
                {
                }
            }
        }
 public void CustomAttributes()
 {
     ArrayList expectedValues = new ArrayList(new int[] { 12, 34, 56 });
     MyAttribute[] attributes = (MyAttribute[]) JsonRpcServices.GetClassFromType(typeof(TestService)).GetMethodByName("Foo").GetCustomAttributes(typeof(MyAttribute));
     Assert.AreEqual(3, attributes.Length);
     foreach (MyAttribute attribute in attributes)
         expectedValues.Remove(attribute.TestValue);
     Assert.AreEqual(0, expectedValues.Count);
 }
Example #24
0
        static void Main(string[] args)
        {
            Console.WriteLine("Basic Array List Testing:");
            ArrayList al = new ArrayList();
            al.Add("Hello");
            al.Add("World");
            al.Add(5);
            al.Add(new FileStream("deleteme", FileMode.Create));

            Console.WriteLine("The array has " + al.Count + " items");

            foreach (object o in al)
            {
                Console.WriteLine(o.ToString());
            }

            Console.WriteLine("\nRemove, Insert and Sort Testing:");
            al = new ArrayList();
            al.Add("Hello");
            al.Add("World");
            al.Add("this");
            al.Add("is");
            al.Add("a");
            al.Add("test");

            Console.WriteLine("\nBefore:");
            foreach (object s in al)
                Console.WriteLine(s.ToString());


            al.Remove("test");
            al.Insert(4, "not");

            al.Sort();

            Console.WriteLine("\nAfter:");
            foreach (object s in al)
                Console.WriteLine(s.ToString());

            al.Sort(new reverseSorter());
            Console.WriteLine("\nReversed:");
            foreach (object s in al)
                Console.WriteLine(s.ToString());

            al.Reverse();
            Console.WriteLine("\nReversed again, different method:");
            foreach (object s in al)
                Console.WriteLine(s.ToString());

            Console.WriteLine("\nBinary Search Example:");
            al = new ArrayList();
            al.AddRange(new string[] { "Hello", "World", "this", "is", "a", "test" });
            foreach (object s in al)
                Console.Write(s + " ");
            Console.WriteLine("\n\"this\" is at index: " + al.BinarySearch("this"));
        }
        internal SoapParameters(XmlMembersMapping request, XmlMembersMapping response, string[] parameterOrder, CodeIdentifiers identifiers) {
            ArrayList requestList = new ArrayList();
            ArrayList responseList = new ArrayList();

            AddMappings(requestList, request);
            if (response != null) AddMappings(responseList, response);

            if (parameterOrder != null) {
                for (int i = 0; i < parameterOrder.Length; i++) {
                    string elementName = parameterOrder[i];
                    XmlMemberMapping requestMapping = FindMapping(requestList, elementName);
                    SoapParameter parameter = new SoapParameter();
                    if (requestMapping != null) {
                        if (RemoveByRefMapping(responseList, requestMapping))
                            parameter.codeFlags = CodeFlags.IsByRef;
                        parameter.mapping = requestMapping;
                        requestList.Remove(requestMapping);
                        AddParameter(parameter);
                    }
                    else {
                        XmlMemberMapping responseMapping = FindMapping(responseList, elementName);
                        if (responseMapping != null) {
                            parameter.codeFlags = CodeFlags.IsOut;
                            parameter.mapping = responseMapping;
                            responseList.Remove(responseMapping);
                            AddParameter(parameter);
                        }
                    }
                }
            }

            foreach (XmlMemberMapping requestMapping in requestList) {
                SoapParameter parameter = new SoapParameter();
                if (RemoveByRefMapping(responseList, requestMapping))
                    parameter.codeFlags = CodeFlags.IsByRef;
                parameter.mapping = requestMapping;
                AddParameter(parameter);
            }

            if (responseList.Count > 0) {
                if (!((XmlMemberMapping) responseList[0]).CheckSpecified) {
                    ret = (XmlMemberMapping)responseList[0];
                    responseList.RemoveAt(0);
                }
                foreach (XmlMemberMapping responseMapping in responseList) {
                    SoapParameter parameter = new SoapParameter();
                    parameter.mapping = responseMapping;
                    parameter.codeFlags = CodeFlags.IsOut;
                    AddParameter(parameter);
                }
            }

            foreach (SoapParameter parameter in parameters) {
                parameter.name = identifiers.MakeUnique(CodeIdentifier.MakeValid(parameter.mapping.MemberName));
            }
        }
Example #26
0
		public static Mnozina operator - (Mnozina a, Mnozina b)
		{
			ArrayList rozdil = new ArrayList();
			rozdil.AddRange(a.seznam);
			foreach(int x in b.seznam)
			{
				rozdil.Remove(x);
			}
			return new Mnozina(rozdil);
		}
        //前回のローカルデータから新規ローカルデータの作成
        public object Apply(object oldValue, NCMBObject obj, string key)
        {
            //前回のローカルデータ(estimatedDataに指定のキーが無い場合)がNullの場合
            if (oldValue == null) {
                //return new List<object> ();
                return new ArrayList ();//追加
            }
            //配列のみリムーブ実行
            if ((oldValue is IList)) {

                //削除処理を行う
                //ArrayList result = new ArrayList ((IList)oldValue);
                //result = NCMBUtility._removeAllFromListMainFunction ((IList)oldValue, this.objects);

                //取り出したローカルデータから今回の引数で渡されたオブジェクトの削除
                ArrayList result = new ArrayList ((IList)oldValue);
                foreach (object removeObj in this.objects) {
                    while (result.Contains(removeObj)) {//removeAllと同等
                        result.Remove (removeObj);
                    }
                }
                //以下NCMBObject重複処理
                //今回引数で渡されたオブジェクトから1.のオブジェクトの削除
                ArrayList objectsToBeRemoved = new ArrayList ((IList)this.objects);

                foreach (object removeObj2 in result) {
                    while (objectsToBeRemoved.Contains(removeObj2)) {//removeAllと同等
                        objectsToBeRemoved.Remove (removeObj2);
                    }
                }

                //結果のリスト(引数)の中のNCMBObjectがすでに保存されている場合はobjectIdを返す
                HashSet<object> objectIds = new HashSet<object> ();
                foreach (object hashSetValue in objectsToBeRemoved) {
                    if (hashSetValue is NCMBObject) {
                        NCMBObject valuesNCMBObject = (NCMBObject)hashSetValue;
                        objectIds.Add (valuesNCMBObject.ObjectId);
                    }

                    //resultの中のNCMBObjectからobjectIdsの中にあるObjectIdと一致するNCMBObjectの削除
                    object resultValue;
                    for (int i = 0; i < result.Count; i++) {
                        resultValue = result [i];
                        if (resultValue is NCMBObject) {
                            NCMBObject resultNCMBObject = (NCMBObject)resultValue;
                            if (objectIds.Contains (resultNCMBObject.ObjectId)) {
                                result.RemoveAt (i);
                            }
                        }
                    }
                }
                return result;
            }
            throw new  InvalidOperationException ("Operation is invalid after previous operation.");
        }
 static void Main(string[] args)
 {
     ArrayList liste = new ArrayList { "Robert", "Markus", "Papa", "Ines" };
     Console.WriteLine("-------------Schreibe Liste-------------");
     PrintListe(liste);
     Console.WriteLine("Liste geschrieben \n\n");
     liste.Remove("Robert");
     Console.WriteLine("-------------Schreibe neue Liste --------------");
     PrintListe(liste);
     Console.ReadLine();
 }
Example #29
0
        public System.Collections.IEnumerable GetBaseTypeFullNameList(object type)
        {
            TypeDefinition t = (TypeDefinition) type;
            AssemblyDefinition asm = GetAssemblyDefinition (t);

            ArrayList list = new ArrayList ();
            Hashtable visited = new Hashtable ();
            GetBaseTypeFullNameList (visited, list, asm, t);
            list.Remove (t.FullName);
            return list;
        }
		private static void AssertArraysAreEqualUnsorted(object[] expected, object[] actual)
		{
			Assert.AreEqual(expected.Length, actual.Length);
			ArrayList actualAsList = new ArrayList(actual);
			foreach(object expectedElement in expected)
			{
				Assert.Contains(expectedElement, actualAsList);
				actualAsList.Remove(expectedElement);
					// need to remove the element after it has been found to guarantee that duplicate elements are handled correctly
			}
		}