1
0
mirror of https://github.com/kalmarek/Groups.jl.git synced 2024-12-25 02:05:30 +01:00

move hash

This commit is contained in:
kalmar 2017-05-11 18:00:46 +02:00
parent cf4529dce6
commit 4718c40bd1

View File

@ -54,6 +54,10 @@ convert{T<:GSymbol, W<:Word}(::Type{W}, s::T) = GWord{T}(s)
function hash(W::GWord, h::UInt)
W.modified && reduce!(W)
return W.savedhash $ h
end
end end
length(W::GWord) = sum([length(s) for s in W.symbols]) length(W::GWord) = sum([length(s) for s in W.symbols])
@ -89,10 +93,6 @@ end
reduce(W::GWord) = reduce!(deepcopy(W)) reduce(W::GWord) = reduce!(deepcopy(W))
function hash{T}(W::GWord{T}, h::UInt)
W.modified && reduce!(W)
return W.savedhash + h
end
function (==){T}(W::GWord{T}, Z::GWord{T}) function (==){T}(W::GWord{T}, Z::GWord{T})
W.modified && reduce!(W) # reduce clears the flag and recalculate the hash W.modified && reduce!(W) # reduce clears the flag and recalculate the hash