Skip to content

Commit

Permalink
Add length methods for IntSet and Set types.
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanKarpinski committed Jun 15, 2011
1 parent 10acfe9 commit cf87fd8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions j/intset.j
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ function choose(s::IntSet)
n
end

length(s::IntSet) = numel(s)
numel(s::IntSet) =
int32(ccall(:bitvector_count, Uint64, (Ptr{Uint32}, Uint32, Uint64),
s.bits, uint32(0), uint64(s.limit)))
Expand Down
1 change: 1 addition & 0 deletions j/table.j
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ next(t::HashTable, i) = ((n, nxt) = next(t.used, i);
((t.keys[n],t.vals[n]),
skip_deleted(t.used,t.deleted,nxt)))

length(t::HashTable) = length(t.used)

This comment has been minimized.

Copy link
@JeffBezanson

JeffBezanson Jun 15, 2011

Member

Should be length(t.used)-length(t.deleted)

isempty(t::HashTable) = done(t, start(t))

function ref(t::Union(IdTable,HashTable), key)
Expand Down

0 comments on commit cf87fd8

Please sign in to comment.