Skip to content

Add dbm methods #9

@larsch

Description

@larsch

Some of the other dbm libraries have a lot of hash-like methods such as has_key?, each, etc. Should consider adding some of these.

I've been tinkering here: https://github.com/larsch/unqlite-ruby/commits/dbm-methods-2, but not all methods are added yet. Looking for comments before I go ahead with more of them.

Comparing to GDBM, here are the methods:

Exists: #close, #delete, #fetch, #store

Straight forward: ::open, #[], #[]=, #closed?, #each, #each_key, #each_pair, #each_value, #has_key?, #include?, #key?, #member?

Would be convenient: #clear, #empty?

Possible but somewhat complex: #delete_if, #has_value?, #invert, #keys, #length, #reject, #reject!, #select, #shift, #size, #to_a, #to_hash, #update, #value?, #values, #values_at, #key, #replace.

The last group are all for Hash-like behaviour, but most are not that simple to implement, and have non-obvious runtime complexity. E.g. #size would have to iterate over all elements to count them (GDBM does that too). Some of them could be done in Ruby instead of C (e.g. to_hash, values_at, etc.).

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions