/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for Additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
/* ================================================================
* About NPOI
* Author: Tony Qu
* Author's email: tonyqus (at) gmail.com
* Author's Blog: tonyqus.wordpress.com.cn (wp.tonyqus.cn)
* HomePage: http://www.codeplex.com/npoi
* Contributors:
*
* ==============================================================*/
using System;
using System.Collections;
namespace HH.WMS.Utils.NPOI.Util.Collections
{
///
/// This class comes from Java
///
public class HashSet: ISet
{
private readonly Hashtable impl = new Hashtable();
///
/// Initializes a new instance of the class.
///
public HashSet()
{
}
///
/// Initializes a new instance of the class.
///
/// The s.
public HashSet(ISet s)
{
foreach (object o in s)
{
Add(o);
}
}
///
/// Adds the specified o.
///
/// The o.
public void Add(object o)
{
impl[o] = null;
}
///
/// Determines whether [contains] [the specified o].
///
/// The o.
///
/// true if [contains] [the specified o]; otherwise, false.
///
public bool Contains(object o)
{
return impl.ContainsKey(o);
}
///
/// Copies the elements of the to an , starting at a particular index.
///
/// The one-dimensional that is the destination of the elements copied from . The must have zero-based indexing.
/// The zero-based index in at which copying begins.
///
/// is null.
///
///
/// is less than zero.
///
///
/// is multidimensional.
/// -or-
/// is equal to or greater than the length of .
/// -or-
/// The number of elements in the source is greater than the available space from to the end of the destination .
///
///
/// The type of the source cannot be cast automatically to the type of the destination .
///
public void CopyTo(Array array, int index)
{
impl.Keys.CopyTo(array, index);
}
///
/// Gets the number of elements contained in the .
///
///
///
/// The number of elements contained in the .
///
public int Count
{
get { return impl.Count; }
}
///
/// Returns an enumerator that iterates through a collection.
///
///
/// An object that can be used to iterate through the collection.
///
public IEnumerator GetEnumerator()
{
return impl.Keys.GetEnumerator();
}
///
/// Gets a value indicating whether access to the is synchronized (thread safe).
///
///
/// true if access to the is synchronized (thread safe); otherwise, false.
///
public bool IsSynchronized
{
get { return impl.IsSynchronized; }
}
///
/// Removes the specified o.
///
/// The o.
public void Remove(object o)
{
impl.Remove(o);
}
///
/// Gets an object that can be used to synchronize access to the .
///
///
///
/// An object that can be used to synchronize access to the .
///
public object SyncRoot
{
get { return impl.SyncRoot; }
}
///
/// Removes all of the elements from this set.
/// The set will be empty after this call returns.
///
public void Clear()
{
impl.Clear();
}
}
}