Skip to content

HTAdd silently accepts adding the same key again, adds into new slot #30

@fingolfin

Description

@fingolfin

Example:

gap> SetInfoLevel(InfoOrb, 3);
gap> ht := HTCreate(1, rec(hashlen:=5));
<hash table obj len=5 used=0 colls=0 accs=0 (can grow)>
gap> ht := HTCreate(1, rec(hashlen:=3));
<hash table obj len=3 used=0 colls=0 accs=0 (can grow)>
gap> HTAdd(ht,1,1);; HTValue(ht, 1);
1
gap> HTAdd(ht,1,2);; HTValue(ht, 1);
1
gap> HTAdd(ht,1,3);; HTValue(ht, 1);
1
gap> HTAdd(ht,1,4);; HTValue(ht, 1);
#I  Hash table too full, growing...
#I  Growing hash table to length 11 !!!
#I  Done.
2

Expected behaviour: I would expect HTAdd to report an error; or at least warning, and then drop the new value. Alternatively, it could also update (which then render HTUpdate obsolete)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions