big-types
Version, currently 0.1.12 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.
Installation
# Add this to your shard.yml
dependencies:
big-types:
github: philipp-classen/big-types.cr
version: ~> 0.1.1Then run:
shards installshard.yml
- Crystal
>= 1.13.1- License
- MIT
- Author
- Philipp Claßen
Dependencies
This version declares no dependencies.
README
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.1- Tagged
- Nov 12, 2024
- Commit
ff55d8d48644- Crystal
>= 1.13.1- Indexed
- yes
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