NoiseFilter: Dont drop last word of apparent hostnames. Too many non-hostnames can...
[beagle.git] / Util / SemWeb / Util.cs
blob3ea36ba04e5e29948b1370191aeb1c43ea4c6c98
1 using System;
2 using System.Collections;
4 using SemWeb;
6 namespace SemWeb.Util {
8 internal class ResSet : ICollection {
9 Hashtable items = new Hashtable();
10 ICollection keys;
12 public ResSet() {
15 private ResSet(Hashtable items) {
16 this.items = items;
19 public void Add(Resource res) {
20 items[res] = items;
21 keys = null;
23 public void Remove(Resource res) {
24 items.Remove(res);
25 keys = null;
28 public bool Contains(Resource res) {
29 return items.ContainsKey(res);
32 public ICollection Items {
33 get {
34 if (keys == null)
35 keys = items.Keys;
36 return keys;
40 public void AddRange(ResSet set) {
41 foreach (Resource r in set.Items) {
42 Add(r);
46 public void Clear() {
47 items.Clear();
48 keys = null;
51 public ResSet Clone() {
52 return new ResSet((Hashtable)items.Clone());
55 public int Count { get { return items.Count; } }
57 public IEnumerator GetEnumerator() { return items.Keys.GetEnumerator(); }
59 bool ICollection.IsSynchronized { get { return false; } }
60 object ICollection.SyncRoot { get { return null; } }
62 public void CopyTo(System.Array array, int index) {
63 foreach (Resource r in this)
64 array.SetValue(r, index++);
67 /*Hashtable Intersect(Hashtable x, Hashtable y) {
68 Hashtable a, b;
69 if (x.Count < y.Count) { a = x; b = y; }
70 else { b = x; a = y; }
71 Hashtable c = new Hashtable();
72 foreach (Resource r in a)
73 if (b.ContainsKey(r))
74 c[r] = c;
75 return c;
76 }*/