github.com/tursom/GoCollections@v0.3.10/collections/Hash.go (about) 1 /* 2 * Copyright (c) 2022 tursom. All rights reserved. 3 * Use of this source code is governed by a GPL-3 4 * license that can be found in the LICENSE file. 5 */ 6 7 package collections 8 9 import ( 10 "github.com/tursom/GoCollections/exceptions" 11 "github.com/tursom/GoCollections/lang" 12 ) 13 14 func HashIterable[E lang.Object](iterable Iterable[E]) int32 { 15 hashCode := int32(0) 16 _ = Loop(iterable, func(element E) exceptions.Exception { 17 hashCode = hashCode*31 ^ element.HashCode() 18 return nil 19 }) 20 return hashCode 21 }