Is it necessary to implement hash/compare trait and for Array?
- [x] Compare (done in #1003)
- [ ] Hash (to be discuss)
compare is needed, not sure about hash though
use case for hash: BPE tokenizer. In BPE tokenizer I need to maintain a Map[(Array[Int], Array[Int]), Array[Int]] when merging multi-byte pairs.
I strongly against to add compare and hash to mutable collection types. If it's needed, we can provide Iter::compare and Iter::hash as workaround.
It's another question that should we provide ReadonlyArray?
I have another use case: hash cons when compiling a computation graph.
The const in a computation graph is a FixedArray[Float] (or Array[Float]) and I need it to be hashable so that I can derive Hash for my graph data type.
I agree we should add hash for Array, user can always misuse HashMap if they want