This Hashable package defines a class, Hashable, for types that can be converted to a hash value. This class exists for the benefit of hashing-based data structures. The package provides instances for basic types and a way to combine hash values.
Questions tagged [hashable]
161 questions
0
votes
1 answer
Is there another way to avoid duplication of large hashable objects?
I am processing text and have the need to store large sequences of hashable objects - sometimes strings, sometimes tuples of words, etc. I've been thinking of using the hash function to provide an simple store and retrieve class but with my first…

bmacnaughton
- 4,950
- 3
- 27
- 36
0
votes
3 answers
Making a list subclass hashable
I want to derive a class from list, add a few instance attributes to it, and make it hashable. What is a good (fast and neat) way to do it?
UPDATE:
I deleted a lengthy explanation of a use case. I also moved a related but separate issue into a…

max
- 49,282
- 56
- 208
- 355
-1
votes
2 answers
Dict to tuple : why does it not take all values?
I converted a dictionary to tuple so it can be hashable.
DATA_ILLUMINANTS = {
'LED': tuple({
380.0: 0.006,
385.0: 0.013,
...
780.0: 0.108,})
}
When I print the tuple, there is not the second column of data, it is :
(380.0,…

гиви
- 79
- 7
-1
votes
1 answer
Different results with Set altough similar code? What is the excact problem in Swift?
i have a small problem. I have two Arrays where i try to find the same content in it. So i decided to convert it to a Set and then using those nice functions with "subtract". However i get very different results. Can someone tell me why this…

esen
- 90
- 5
-1
votes
2 answers
will hasher.combine(self) cause trouble while using collections?
Can using this implementation of hash(into:) cause problems, especially using collections and arrays?:
func hash(into hasher: inout Hasher){
hasher.combine(self)
}

Hamoonist
- 2,286
- 3
- 19
- 36
-1
votes
1 answer
Generating Identification Number of String Bundle
Assume that you have a struct called bundle and it consists of string objects. There is no accurate knowledge about how many strings a bundle will contain, and you need to generate identification number for each bundle so that you can differentiate…

Goktug
- 855
- 1
- 8
- 21
-1
votes
1 answer
Implementing Hashable and NSCoding in the same class in Swift
I am having an issue trying to adopt the Hashable and NSCoding protocols within the same Swift class (or struct). Hashability and encode/decode both work independently. However, hashability is lost once an object has been restored by…

ksgg
- 31
- 3
-1
votes
1 answer
Swift : Why is it required for the key type in a Dictionary to be of type Hashable
If I want to create a Dictionary() it is required for the Key type object to the protocol Hashable. Why is that the case, how are Dictionaries implemented?
I mean I would understand that if the Key just needs to conform to the protocol…

rahulg
- 2,183
- 3
- 33
- 47
-1
votes
3 answers
Python: looking for duplicates in list
I have a list of floats, and I want to know how many duplicates are in it.
I have tried with this:
p = t_gw.p(sma, m1, m2) #p is a 1d numpy array
p_list = list(p)
dup = set([x for x in p_list if p_list.count(x) > 1])
print dup
I have also…

Argentina
- 1,071
- 5
- 16
- 30
-2
votes
1 answer
'Hashable.hashValue' is deprecated as a protocol requirement; conform type 'CarnivalWheel' to 'Hashable' by implementing 'hash(into:)' instead
Cant seem to get the hash(into:) changed correctly? everything i try just brings a new error
Any help on this would be appreciated,
Swift 5
import UIKit
import TTFortuneWheel
class CarnivalWheel: FortuneWheelSliceProtocol, Codable, Hashable {
…

Jamesnjones
- 41
- 6
-2
votes
3 answers
What the difference between hash-able and immutable?
What's the difference between immutable and hash-able ?
What does this mean "An object is hashable if it has a hash value which never changes during its lifetime?"
Is a tuple immutable and hashable or only immutable ? why ?

N.Elsayed
- 440
- 1
- 4
- 12