big-types
Version, currently 0.1.02 versions
- 0.1.1latestNov 12, 2024
- 0.1.0not indexedNov 12, 2024
github.com/philipp-classen/big-types.cr
Drop-in replacements for Array, Set, and Hash in Crystal, but not limited to 32-bit indexes.
Nothing has been indexed for 0.1.0 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.
Installation
# Add this to your shard.yml
dependencies:
big-types:
github: philipp-classen/big-types.cr
version: ~> 0.1.0Then run:
shards installshard.yml
No shard.yml has been indexed for 0.1.0. You can read it on the repository.
Dependencies
Unknown: the shard.yml for this version has not been read yet.
README
This README is the one indexed from the repository at its latest ref, not from the tag for this version.
big-types
Provides data structures that serve as drop-in replacements for Array, Hash, and Set. Unlike the standard types, these structures support sizes that exceed 32-bit indices.
The implementation is based on the Crystal standard library, with 32-bit integers replaced by 64-bit integers.
require "big-types"
x = BigArray(Int32).new # like Array(Int32).new
y = BigSet(Int32).new # like Set(Int32).new
z = BigHash(Int32, Int32).new # like Hash(Int32, Int32).new
Installation
-
Add the dependency to your
shard.yml:dependencies: big-types: github: philipp-classen/big-types.cr -
Run
shards install
Usage
require "big-types/big_array"
x = BigArray(Int8).new
4_000_000_000.times { x << 0 }
p! x.size
Note that the equivalent program using standard Array would have overflowed:
x = Array(Int8).new
4_000_000_000.times { x << 0 }
Unhandled exception: Arithmetic overflow (OverflowError)
from /usr/lib/crystal/int.cr:568:7 in '__crystal_main'
from /usr/lib/crystal/crystal/main.cr:118:5 in 'main'
from /usr/lib/libc.so.6 in '??'
from /usr/lib/libc.so.6 in '__libc_start_main'
from /tmp/phil-crystal-cache-dir/crystal-run-overflow.tmp in '_start'
from ???
The equivalent to Set is BigSet:
require "big-types/big_set"
x = BigSet(Int64).new
4_000_000_000.times { |i| x << i }
p! x.size
And, finally, the equivalent to Hash is BigHash:
require "big-types/big_hash"
x = BigHash(Int64, Int8).new
4_000_000_000.times { |i| x[i] = 0_i8 }
p! x.size
Development
The code base should stay as close as possible to the implementation in the Crystal standard library.
Contributing
- Fork it (https://github.com/philipp-classen/big-types/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- Philipp Claßen - creator and maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.1.0- Tagged
- Nov 12, 2024
- Commit
05a54f0a4e07- Indexed
- not yet
Dependents
No indexed shard depends on this one yet.
Repository
github.com/philipp-classen/big-types.cr
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 16, 2026
- Synced
- Aug 16, 2026
- Versions
- 2