您的位置:首页 > 移动开发 > Objective-C

Using HashTable to realize a set which Provide a collection that contains a group of unique objects

2007-05-09 10:41 585 查看
using System;
2using System.Collections;
3namespace Utilities
4{
5 /**//// <summary>
6 /// Provide a collection that contains a group of unique
7 /// objects.
8 /// </summary>
9 public class Set
10 {
11 private Hashtable h = new Hashtable();
12 /**//// <summary>
13 /// Return an enumerator for this set.
14 /// </summary>
15 /// <returns>An enumerator for this set</returns>
16 public IEnumerator GetEnumerator()
17 {
18 return h.Keys.GetEnumerator();
19 }
20 /**//// <summary>
21 /// Add the provided object to this set.
22 /// </summary>
23 /// <param name="o">the object to add</param>
24 public void Add(Object o)
25 {
26 h[o] = null;
27 }
28 /**//// <summary>
29 /// Return true if the set contains the presented object.
30 /// </summary>
31 /// <param name="o">the object of curiosity</param>
32 /// <returns>true, if the set contains the presented object</returns>
33 public bool Contains(Object o)
34 {
35 return h.Contains(o);
36 }
37 }
38}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐