## Description
Currently, the signature for `Table.Get` is `func (K) (V, error)`. This is not very Go-idiomatic, which prefers to return a boolean instead of an error. For instance, a built-in Go map is used like so:
```go
if value, ok := users[id]; !ok {
// ...
}
```
Updating our table to look like that is best practice. In that same vein, to support direct lookup (i.e. `v := users[id]`), this PR also adds `Table.Find`.
## Changes
- BREAKING CHANGE: Update contract of `Table.Get` to `func (K) (V, bool)`. Returns 'false' is the item cannot be found, and 'true' if it is found.
- Add `Table.Find`.
- Updated tests and documentation to match the change.
### Design Decisions
- Chose to make this decision because throwing an error implies that there is something 'wrong' with the table. There is nothing wrong with the table; it is just that the item does not exist.
## Checklist
- [x] Tests pass
- [x] Docs updated
Reviewed-on: #20
Co-authored-by: M.V. Hutz <git@maximhutz.me>
Co-committed-by: M.V. Hutz <git@maximhutz.me>
## Description
Currently, the errors are not sentinel, and so are hard to test for. This PR makes sure hash collision errors are accounted for.
## Changes
- Add `ErrBadHash`. Happens when there are too many collisions for an item to be added.
### Design Decisions
- Chose to name `ErrBadHash` over `ErrCycle` because the feedbach that the user should be given is to evaluate their hash functions. Cycle collision is a bit esoteric.
## Checklist
- [x] Tests pass
- [x] Docs updated
Reviewed-on: #19
Co-authored-by: M.V. Hutz <git@maximhutz.me>
Co-committed-by: M.V. Hutz <git@maximhutz.me>
## Description
The `cuckoo.MinimumLoad()` option was not a very useful option, and prone to error. By removing the ability to modify it, and setting it to something reasonable (like 5%), we can remove a whole set of errors that the user may stumble into.
## Changes
- Remove `MinimumLoad()` option.
- Privated `DefaultMinimumLoad`.
### Design Decisions
- `DefaultMinimumLoad` should be privated because it is no longer an option. The user should not need to interact with it.
## Checklist
- [x] Tests pass
- [x] Docs updated
Reviewed-on: #17
## Description
Currently, the `check-pr-title` job has a security vulnerability. If you give the PR a bad title, the job can run arbitrary code.
## Changes
- Fix prompt injection by pulling the PR title as an environment variable.
- Also, restricted the job to only `pull_request` trigger.
### Design Decisions
- It is better to pull out this job into a separate workflow with a unique trigger, but I chose not to because it is currently only one job.
## Checklist
- [x] Tests pass
- [x] Docs updated
Reviewed-on: #18
Co-authored-by: M.V. Hutz <git@maximhutz.me>
Co-committed-by: M.V. Hutz <git@maximhutz.me>
## Description
There were some problems with the roll-out of the issue templates. This PR addresses them.
## Changes
- Disable `blank-issue-enabled`.
- Move all `description` types in the issue templates to `placeholder`.
### Design Decisions
- The `description` fields take up too much space.
## Checklist
- [x] Tests pass
- [x] Docs updated
Reviewed-on: #16
Co-authored-by: M.V. Hutz <git@maximhutz.me>
Co-committed-by: M.V. Hutz <git@maximhutz.me>
## Description
Currently, the repository is not well suited for semantic versioning, and hasn't much to support it. This PR adds templates, CI jobs, and configs to simplify its adoption.
## Changes
- Added `FEATURE` and `BUG` issue templates. Also, forbids free-form issues.
- Adds a PR template.
- Adds a CI job to ensure the commit title follows conventional commits.
### Design Decisions
N/A.
## Checklist
- [x] Tests pass
- [x] Docs updated
Reviewed-on: #15
Co-authored-by: M.V. Hutz <git@maximhutz.me>
Co-committed-by: M.V. Hutz <git@maximhutz.me>
There shouldn't be a global settings folder for Claude in the repository. Also, add final newline to `.gitignore`.
Reviewed-on: #14
Co-authored-by: M.V. Hutz <git@maximhutz.me>
Co-committed-by: M.V. Hutz <git@maximhutz.me>
- Added all `Option`-s to the fuzz tests.
- Minimum load is always <=20%.
- Tested all options, and force a panic on all invalid options.
- Capacity must now be non-negative.
- Minimum load should be <=20%, but just put it as a recommendation.
Reviewed-on: #9
Co-authored-by: M.V. Hutz <git@maximhutz.me>
Co-committed-by: M.V. Hutz <git@maximhutz.me>
This test offers the same functionality as `TestAddItem`.
Reviewed-on: #8
Co-authored-by: M.V. Hutz <git@maximhutz.me>
Co-committed-by: M.V. Hutz <git@maximhutz.me>
Currently, the `Table.Drop()` function is deprecated because it is not implemented yet. Let's add that functionality.
- Adds true drop functionality to the table, through `Table.Drop()`.
- Adds tests for functionality.
- Rewrites fuzz test using `go_fuzz_utils`, to test arbitrary usage patterns.
- Rewrite `bucket` to allow a capacity of zero.
- Rename `Table.Capacity()` to `Table.TotalCapacity()`, to reflect to different between the capacity of the buckets vs. the whole table.
- Enforce 100% mutation test coverage.
Reviewed-on: #6
Co-authored-by: M.V. Hutz <git@maximhutz.me>
Co-committed-by: M.V. Hutz <git@maximhutz.me>
Currently, there is no CI job to lint the Makefile. This adds one.
Reviewed-on: #5
Co-authored-by: M.V. Hutz <git@maximhutz.me>
Co-committed-by: M.V. Hutz <git@maximhutz.me>
Currently, the `Makefile` is not well structured, and does not follow best practices. With the help of [`checkmake`](https://github.com/checkmake/checkmake), the Makefile can be forced to follow them.
### Decisions
- Added CI job `lint-makefile`, which forces the Makefile to conform to standards.
- The `make help` was set as the default target. This is common practice in the industry.
- The `make help` uses `grep` | `awk` to create a command table from `##` comments after each target. It seems a bit icky, but it is something that Docker, Kubernetes, and Helm all do.
Reviewed-on: #4
Co-authored-by: M.V. Hutz <git@maximhutz.me>
Co-committed-by: M.V. Hutz <git@maximhutz.me>
## Description
The current CI workflow was auto-generated by Claude, and is really not intuitive. Fixing it up to make it work better.
- Add names for jobs in workflow.
- Rename workflow to `ci.yml`.
- Added `go mod tidy` as a tasks in the `lint` job.
### Decisions
- Chose not to use emojis for workflow or job names. While they look nice, they are unprofessional, and harder to `grep`.
Reviewed-on: #3
Co-authored-by: M.V. Hutz <git@maximhutz.me>
Co-committed-by: M.V. Hutz <git@maximhutz.me>
The `ExampleEqualFunc_badEqualFunc` was non-deterministic, because the hashes used in the `CustomTable` could (by chance) map "Rob" and "Robert" to the same slot.
- Updated the test to use a deterministic hash.
Reviewed-on: #2
Co-authored-by: M.V. Hutz <git@maximhutz.me>
Co-committed-by: M.V. Hutz <git@maximhutz.me>
Moved the implementation of this hash table from `tools/dsa` #1.
Reviewed-on: #1
Co-authored-by: M.V. Hutz <git@maximhutz.me>
Co-committed-by: M.V. Hutz <git@maximhutz.me>