File 2578-is_empty-1-for-sets.patch of Package erlang

From 35ae53a6c37c670fdfe1e3ea8dc118e443febbf3 Mon Sep 17 00:00:00 2001
From: "j.uhlig" <j.uhlig@mailingwork.de>
Date: Mon, 19 Mar 2018 16:32:41 +0100
Subject: [PATCH 2/4] is_empty/1 for sets

---
 lib/stdlib/doc/src/sets.xml | 9 +++++++++
 lib/stdlib/src/sets.erl     | 8 +++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/lib/stdlib/doc/src/sets.xml b/lib/stdlib/doc/src/sets.xml
index 4934bed365..1ed96ddc3f 100644
--- a/lib/stdlib/doc/src/sets.xml
+++ b/lib/stdlib/doc/src/sets.xml
@@ -139,6 +139,15 @@
       </desc>
     </func>
 
+    <func>
+      <name name="is_empty" arity="1"/>
+      <fsummary>Test for empty set.</fsummary>
+      <desc>
+        <p>Returns <c>true</c> if <c><anno>Set</anno></c> is an empty set,
+          otherwise <c>false</c>.</p>
+      </desc>
+    </func>
+
     <func>
       <name name="is_set" arity="1"/>
       <fsummary>Test for a <c>Set</c>.</fsummary>
diff --git a/lib/stdlib/src/sets.erl b/lib/stdlib/src/sets.erl
index c65a13b22e..ac0fc80526 100644
--- a/lib/stdlib/src/sets.erl
+++ b/lib/stdlib/src/sets.erl
@@ -37,7 +37,7 @@
 -module(sets).
 
 %% Standard interface.
--export([new/0,is_set/1,size/1,to_list/1,from_list/1]).
+-export([new/0,is_set/1,size/1,is_empty/1,to_list/1,from_list/1]).
 -export([is_element/2,add_element/2,del_element/2]).
 -export([union/2,union/1,intersection/2,intersection/1]).
 -export([is_disjoint/2]).
@@ -96,6 +96,12 @@ is_set(_) -> false.
       Set :: set().
 size(S) -> S#set.size. 
 
+%% is_empty(Set) -> boolean().
+%%  Return 'true' if Set is an empty set, otherwise 'false'.
+-spec is_empty(Set) -> boolean() when
+      Set :: set().
+is_empty(S) -> S#set.size=:=0.
+
 %% to_list(Set) -> [Elem].
 %%  Return the elements in Set as a list.
 -spec to_list(Set) -> List when
-- 
2.16.3

openSUSE Build Service is sponsored by