Skip to content

Commit

Permalink
Small cleanup for library(nb_set).
Browse files Browse the repository at this point in the history
  • Loading branch information
JanWielemaker committed Nov 1, 2024
1 parent 61d5296 commit 64c7b19
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions library/nb_set.pl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
nb_set_to_list/2, % +Set, -List
gen_nb_set/2 % +Set, -Key
]).
:- autoload(library(apply), [maplist/2]).
:- autoload(library(terms), [term_factorized/3]).
:- use_module(library(debug), [assertion/1]).

Expand Down Expand Up @@ -100,7 +99,7 @@
nb_setarg(KIndex, Buckets, Key),
NSize is Size+1,
nb_setarg(3, Set, NSize),
( NSize > Capacity*0.5
( NSize > Capacity//2
-> rehash(Set)
; true
)
Expand All @@ -120,11 +119,8 @@

next(KIndex, _, KIndex).
next(KIndex0, Capacity, KIndex) :-
KIndex1 is KIndex0+1,
( KIndex1 < Capacity
-> next(KIndex1, Capacity, KIndex)
; next(1, Capacity, KIndex)
).
KIndex1 is 1+(KIndex0 mod Capacity),
next(KIndex1, Capacity, KIndex).

rehash(Set) :-
Set = nb_set(Empty, Capacity, Size, Buckets),
Expand Down

0 comments on commit 64c7b19

Please sign in to comment.