riak / src / vclock.erl

Diff from to

src/vclock.erl

 -author('Andy Gross <andy@basho.com>').
 
 -export([fresh/0,descends/2,merge/1,get_counter/2,get_timestamp/2,
-	increment/2,all_nodes/1]).
+	increment/2,all_nodes/1,equal/2]).
 -export([example_test/0]).
 
 % @type vclock() = [vc_entry].
 all_nodes(VClock) ->
     [X || {X,{_,_}} <- VClock].
 
+% @private
 timestamp() ->
     calendar:datetime_to_gregorian_seconds(erlang:universaltime()).
+
+% @doc Compares two VClocks for equality.
+%      Not very fast.
+% @spec equal(VClockA :: vclock(), VClockB :: vclock()) -> true | false
+equal(VA,VB) ->
+    VSet1 = sets:from_list(VA),
+    VSet2 = sets:from_list(VB),
+    case length(sets:to_list(sets:subtract(VSet1,VSet2))) > 0 of
+        true -> false;
+        false ->
+            case length(sets:to_list(sets:subtract(VSet2,VSet1))) > 0 of
+                true -> false;
+                false -> true
+            end
+    end.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.