root/apps/outlook/branches/1.5/DotTelSystem/Punycode/generate/HashSet.cs
@
580
| Revision 580, 2.9 kB (checked in by jonmaycock, 10 months ago) |
|---|
| Line | |
|---|---|
| 1 | /// <summary> Copyright (C) 2004 Free Software Foundation, Inc. |
| 2 | /// * |
| 3 | /// Author: Alexander Gnauck AG-Software |
| 4 | /// * |
| 5 | /// This file is part of GNU Libidn. |
| 6 | /// * |
| 7 | /// This library is free software; you can redistribute it and/or |
| 8 | /// modify it under the terms of the GNU Lesser General Public License |
| 9 | /// as published by the Free Software Foundation; either version 2.1 of |
| 10 | /// the License, or (at your option) any later version. |
| 11 | /// * |
| 12 | /// This library is distributed in the hope that it will be useful, but |
| 13 | /// WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | /// Lesser General Public License for more details. |
| 16 | /// * |
| 17 | /// You should have received a copy of the GNU Lesser General Public |
| 18 | /// License along with this library; if not, write to the Free Software |
| 19 | /// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
| 20 | /// USA |
| 21 | /// </summary> |
| 22 | using System; |
| 23 | using System.Collections; |
| 24 | |
| 25 | namespace gnu.inet.encoding.misc |
| 26 | { |
| 27 | /// <summary> |
| 28 | /// HashSet class. |
| 29 | /// </summary> |
| 30 | public class HashSet : ArrayList |
| 31 | { |
| 32 | public HashSet() : base() |
| 33 | { |
| 34 | } |
| 35 | |
| 36 | public HashSet(System.Collections.ICollection c) |
| 37 | { |
| 38 | this.AddAll(c); |
| 39 | } |
| 40 | |
| 41 | public HashSet(int capacity) : base(capacity) |
| 42 | { |
| 43 | } |
| 44 | |
| 45 | /// <summary> |
| 46 | /// Adds a new element to the ArrayList if it is not already present. |
| 47 | /// </summary> |
| 48 | /// <param name="obj">Element to insert to the ArrayList.</param> |
| 49 | /// <returns>Returns true if the new element was inserted, false otherwise.</returns> |
| 50 | new public virtual bool Add(System.Object obj) |
| 51 | { |
| 52 | bool inserted; |
| 53 | |
| 54 | if ((inserted = this.Contains(obj)) == false) |
| 55 | { |
| 56 | base.Add(obj); |
| 57 | } |
| 58 | |
| 59 | return !inserted; |
| 60 | } |
| 61 | |
| 62 | /// <summary> |
| 63 | /// Adds all the elements of the specified collection that are not present to the list. |
| 64 | /// </summary> |
| 65 | /// <param name="c">Collection where the new elements will be added</param> |
| 66 | /// <returns>Returns true if at least one element was added, false otherwise.</returns> |
| 67 | public bool AddAll(System.Collections.ICollection c) |
| 68 | { |
| 69 | System.Collections.IEnumerator e = new System.Collections.ArrayList(c).GetEnumerator(); |
| 70 | bool added = false; |
| 71 | |
| 72 | while (e.MoveNext() == true) |
| 73 | { |
| 74 | if (this.Add(e.Current) == true) |
| 75 | added = true; |
| 76 | } |
| 77 | |
| 78 | return added; |
| 79 | } |
| 80 | |
| 81 | /// <summary> |
| 82 | /// Returns a copy of the HashSet instance. |
| 83 | /// </summary> |
| 84 | /// <returns>Returns a shallow copy of the current HashSet.</returns> |
| 85 | public override System.Object Clone() |
| 86 | { |
| 87 | return base.MemberwiseClone(); |
| 88 | } |
| 89 | } |
| 90 | } |
Note: See TracBrowser
for help on using the browser.








