Created
November 22, 2012 03:57
-
-
Save argv0/4129376 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vclock_to_binary([], Acc, Size) -> | |
VclockSize = size(Acc), | |
<<VclockSize:32/integer, Acc/binary>>; | |
vclock_to_binary([{AId, {Count, TS}}|T], Acc, Size) -> | |
AIdSize = size(AId), | |
vclock_to_binary(T, <<AIdSize:8/integer, AId:AIdSize/binary, Count:64/integer, TS:32/integer, Acc/binary>>, Size+1). | |
binary_to_vclock(<<VclockSize:32/integer, VclockBin:VclockSize/binary, Rest/binary>>) -> | |
binary_to_vclock(VclockBin, []). | |
binary_to_vclock(<<>>, Acc) -> | |
lists:reverse(Acc); | |
binary_to_vclock(<<AIdSize:8/integer, AId:AIdSize/binary, Count:64/integer, TS:32/integer, Rest/binary>>, Acc) -> | |
binary_to_vclock(Rest, [{AId, {Count, TS}}|Acc]). | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment