|
@@ -11,6 +11,7 @@ namespace Invercargill.DataStructures {
|
|
private int n_items = 0;
|
|
private int n_items = 0;
|
|
private int n_buckets = 16;
|
|
private int n_buckets = 16;
|
|
private int n_collissions = 0;
|
|
private int n_collissions = 0;
|
|
|
|
+ private int next_item_index = 0;
|
|
private SafeReadFunc<T>? safe_read;
|
|
private SafeReadFunc<T>? safe_read;
|
|
private SafeWriteFunc<T>? safe_write;
|
|
private SafeWriteFunc<T>? safe_write;
|
|
private HashDelegate<T> hash_func;
|
|
private HashDelegate<T> hash_func;
|
|
@@ -92,8 +93,9 @@ namespace Invercargill.DataStructures {
|
|
|
|
|
|
private uint add_item(T item) {
|
|
private uint add_item(T item) {
|
|
ensure_room_for_items(1);
|
|
ensure_room_for_items(1);
|
|
- write_item(n_items, item);
|
|
|
|
|
|
+ write_item(next_item_index, item);
|
|
n_items++;
|
|
n_items++;
|
|
|
|
+ next_item_index++;
|
|
return n_items;
|
|
return n_items;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -113,9 +115,7 @@ namespace Invercargill.DataStructures {
|
|
public override Tracker<T> get_tracker () {
|
|
public override Tracker<T> get_tracker () {
|
|
return range(0, buckets.length)
|
|
return range(0, buckets.length)
|
|
.where(i => buckets[i] != BUCKET_EMPTY && buckets[i] != BUCKET_TOMBSTONE)
|
|
.where(i => buckets[i] != BUCKET_EMPTY && buckets[i] != BUCKET_TOMBSTONE)
|
|
- .debug_trace("buket number")
|
|
|
|
.select<T>(i => get_item(buckets[i]))
|
|
.select<T>(i => get_item(buckets[i]))
|
|
- .debug_trace("hashset tracker!")
|
|
|
|
.get_tracker();
|
|
.get_tracker();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -191,16 +191,16 @@ namespace Invercargill.DataStructures {
|
|
if(buckets[bucket_index] != BUCKET_TOMBSTONE) {
|
|
if(buckets[bucket_index] != BUCKET_TOMBSTONE) {
|
|
var ours = get_item(buckets[bucket_index]);
|
|
var ours = get_item(buckets[bucket_index]);
|
|
if(equal_func(ours, item)) {
|
|
if(equal_func(ours, item)) {
|
|
- write_item(buckets[bucket_index], null);
|
|
|
|
|
|
+ write_item(buckets[bucket_index] - 1, null);
|
|
buckets[bucket_index] = BUCKET_TOMBSTONE;
|
|
buckets[bucket_index] = BUCKET_TOMBSTONE;
|
|
n_items--;
|
|
n_items--;
|
|
- print(@"Removed $((int)item)\n");
|
|
|
|
return ours;
|
|
return ours;
|
|
}
|
|
}
|
|
|
|
+ else {
|
|
|
|
+ }
|
|
}
|
|
}
|
|
bucket_index++;
|
|
bucket_index++;
|
|
}
|
|
}
|
|
- print(@"Did not remove $((int)item)\n");
|
|
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -208,10 +208,10 @@ namespace Invercargill.DataStructures {
|
|
if(other == this) {
|
|
if(other == this) {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
- return other.debug_trace("other").non_common(this.debug_trace("this"), hash_func, equal_func).debug_trace("Non common").count() == 0;
|
|
|
|
|
|
+ return other.non_common(this, hash_func, equal_func).count() == 0;
|
|
}
|
|
}
|
|
public bool is_subset_of(Enumerable<T> other) {
|
|
public bool is_subset_of(Enumerable<T> other) {
|
|
- return this.exclude(other, hash_func, equal_func).count() == 0;
|
|
|
|
|
|
+ return this.exclude(other, hash_func, equal_func).debug_trace("subset").count() == 0;
|
|
}
|
|
}
|
|
public bool is_proper_subset_of(Enumerable<T> other) {
|
|
public bool is_proper_subset_of(Enumerable<T> other) {
|
|
return !equals(other) && is_subset_of(other);
|
|
return !equals(other) && is_subset_of(other);
|