Questions tagged [hashable]

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.

161 questions
0
votes
1 answer

Swift How Store And Retrieve Set Type

Accessing Set elements is fast, and Set type must to be hashable. I thought so Swift store only hashed-value of each element, but I fount the raw value (not hashed) could also be accessed. e.g like this: var favoriteGenres: Set = ["Rock",…
rick
  • 1,009
  • 2
  • 10
  • 28
0
votes
2 answers

I can't understand the swift language question mark operator in dictionary in this situation transitions[prev]?[transition]

I've searched in a lot of places and communities among the internet to find what the heck is happening in this programing syntax. I'm seeking, desperately, for guidance in this code. What is happening with the compiler in these specific…
0
votes
1 answer

It seems Swfit.AnyHashable is not casing (as!, as?, as) properly with enums

Here is a simple case example of AnyHashable not supporting casting with enums. enum testEnum: String { case Test } let myObject: AnyHashable = testEnum.Test as AnyHashable let newObject = myObject as? testEnum In this case newObject will…
MurderDev
  • 157
  • 1
  • 10
0
votes
1 answer

Swift | Set with NSObject

I'm trying to create a Set with custom objects. This is working, If I use a Set of my custom objects there is no duplicates : public class AttributesGroup: Hashable, Equatable, Comparable { open var id: Int! open var name: String! open…
Aximem
  • 714
  • 8
  • 27
0
votes
1 answer

How does Swift hash Strings?

I'm looking through the Swift implementation of String (https://github.com/apple/swift/blob/master/stdlib/public/core/String.swift) String implements the Hashable protocol, which means that it must provide a hashValue. However, none is provided in…
James Shapiro
  • 4,805
  • 3
  • 31
  • 46
0
votes
1 answer

Leaflet markercluster and hashable

I have a map with a lot of markers in cluster, with the markercluster plug ( which i create thanks to a geojson in .JS file as a variable), and i'm trying to be able to dynamically modify the URL hash with zoom/lat/lng with Hashable.js but…
NanBlanc
  • 127
  • 1
  • 12
0
votes
1 answer

Hashable protocol for a protocol

I am wondering what is wrong with the following code ? import Foundation enum SliderType: Int { case analog = 1, discrete, highLow } protocol DataEntry: class, Hashable { var hashValue: Int { get set } // hashable protocol requires this …
iKK
  • 6,394
  • 10
  • 58
  • 131
0
votes
1 answer

Swift 3.0 notification transformable to array or array of dictionaries?

Getting this data back as a notification and want to read it into usable variable types. I got all of them to work but the rewards and aps %@ [AnyHashable("description"): Open 10 common chests., AnyHashable("icon"): …
Chrisman
  • 3
  • 1
0
votes
1 answer

Is it possible to generate a unique hash from a Swift closure?

Lets say we have the following struct which wraps around a closure: public struct Task: Hashable { pubic var closure: RateLimitedClosure public var hashValue: Int { // return unique hash return 1 } public static…
Sabobin
  • 4,256
  • 4
  • 27
  • 33
0
votes
1 answer

Swift protocol conformance declared in a superclass not detected

I have the following code: import RealmSwift class MyClass:Object{ } func test(){ let set = Set() } I get a compile time error: Type 'MyClass' does not conform to protocol 'Hashable' on this line: let set = Set() MyClass…
hmitkov
  • 359
  • 4
  • 12
0
votes
1 answer

Custom hashable struct for my Dictionary

I'd like to build a hashable value to be used for my dictionary's key. It should consist of a structure with two strings and an NSDate. I'm not sure I built my hashValue getter correctly below: // MARK: comparison function for conforming to…
Daniel
  • 3,758
  • 3
  • 22
  • 43
0
votes
2 answers

Make a list mutable and hashable

An object that is hashable needs a __hash__ method and it has a hash value which never changes during its lifetime. Python lists are not hashable for reasons that I totally ignore and I wonder if the following implementation is OK or if it has some…
Cobry
  • 4,348
  • 8
  • 33
  • 49
0
votes
1 answer

nil is not convertible to hashable.

I have a custom control that is using a datasource to fetch items (as an NSTableView would do). The datasource can return Any-type, as long as it's hashable. The items are used as a key in a private dictionary. The control (custom view) is added to…
user965972
  • 2,489
  • 2
  • 23
  • 39
0
votes
1 answer

Swift 1.2: :0: error: '[Set]' is not convertible to 'Hashable'

I have used xCode 6.3's convertor to convert my project to swift 1.2, After that i was still left with many errors, but i fixed them all manually. Now when i compile i get: :0: error: '[Set]' is not convertible to 'Hashable'. The…
Amitay
  • 468
  • 5
  • 20
0
votes
1 answer

Tried to implement lists as dictionary keys within algorithm, what's a quick solution?

I am trying to implement the Apriori algorithm... http://codeding.com/articles/apriori-algorithm in Python. The highest level data structuring goes something like this: frequentItemSets[ k-level : itemSetDictionary] | …
Gthoma2
  • 687
  • 1
  • 9
  • 22
1 2 3
10
11