Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Where are the examples? #5

Open
1 task done
ok-ryoko opened this issue May 5, 2023 · 0 comments
Open
1 task done

Where are the examples? #5

ok-ryoko opened this issue May 5, 2023 · 0 comments
Labels
documentation Changes to documentation

Comments

@ok-ryoko
Copy link
Owner

ok-ryoko commented May 5, 2023

Code of conduct

  • I have read and agree to the community’s code of conduct.

Scope

I propose the addition of one or more Zig source files to an examples/ directory in the root of the project repository. Each file would emulate client code that imports and builds over multiring.zig. Each file would contain at least one passing test. For example, we could show how to:

  • Use memory allocation to build multirings, e.g., a MultiRingBuilder API
  • Iterate over the data in a multiring, filtering out (skipping) subrings conditionally
  • Sort the data nodes in a ring
  • Find the lowest common superring of any two rings in the same multiring
  • Remove a (long) chain of data nodes in a ring by cutting links at only the endpoints of the chain
  • Use a multiring to index the rings in another multiring

Value proposition

The purpose of this project is to provide a minimal set of low-level operations that facilitate the implementation of algorithms over multirings in client code.

To my knowledge, the multiring is a rarely described data structure. (I have not encountered it in the wild, although it may exist out there in some form and under a different name.) It can therefore be unintuitive to reason about this structure and determine whether it fits one’s use case. By adding examples to this repository, we can make it easier for developers to get started with the data structure and, by extension, increase the project’s accessibility.

Examples can demonstrate the value of this data structure (or the absence thereof, in which case we can save other developers time and energy spent thinking about this structure at all). Without examples, a developer may be less likely to consider this repository for use in their application(s) even when the multiring is a strong model for the data.

Supporting information

To recapitulate, the goal is to prescribe and describe basic idioms for working with multiring.zig. Therefore, the contents of the examples don’t have to be sophisticated, but they must be complete and correct.

If this proposal is accepted, then we should also update the pre-commit hook and CI configuration for Zig source code.

@ok-ryoko ok-ryoko added the documentation Changes to documentation label May 5, 2023
ok-ryoko added a commit that referenced this issue Aug 24, 2023
Consumers of this module will have differing requirements and therefore
differing opinions about the design of a higher-level API over the core
ADT. Differences in requirements will affect, for example, the choice
and implementation of algorithms for sorting, how memory is managed and
how undefined behavior is handled.

So, instead of extending the core ADT, we add an example that shows how
the core ADT, which contains only essential complexity, can be embedded
into a type containing a mixture of accidental and essential complexity.

Relates to #5
ok-ryoko added a commit that referenced this issue Aug 25, 2023
These methods apply to the entire multiring, not to individual rings, to
illustrate the ease with which we can leverage the core ADT's API.

The filter method allows us to omit rings of arbitrary size
conditionally when traversing the multiring. It highlights how the
structure of the multiring can decrease the time complexity of traversal
without increasing the space complexity.

Relates to #5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Changes to documentation
Projects
None yet
Development

No branches or pull requests

1 participant