LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File 1161-is_empty-1-for-ordsets.patch of Package erlang (Project home:Ledest:erlang:20)

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

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

diff --git a/lib/stdlib/doc/src/ordsets.xml b/lib/stdlib/doc/src/ordsets.xml
index 7b590932e4..2d891d7a5a 100644
--- a/lib/stdlib/doc/src/ordsets.xml
+++ b/lib/stdlib/doc/src/ordsets.xml
@@ -141,6 +141,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>Ordset</anno></c> is an empty set,
+          otherwise <c>false</c>.</p>
+      </desc>
+    </func>
+
     <func>
       <name name="is_set" arity="1"/>
       <fsummary>Test for an <c>Ordset</c>.</fsummary>
diff --git a/lib/stdlib/src/ordsets.erl b/lib/stdlib/src/ordsets.erl
index 569407f5ef..939e147ad8 100644
--- a/lib/stdlib/src/ordsets.erl
+++ b/lib/stdlib/src/ordsets.erl
@@ -19,7 +19,7 @@
 
 -module(ordsets).
 
--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]).
@@ -60,6 +60,13 @@ is_set([], _) -> true.
 
 size(S) -> length(S).
 
+%% is_empty(OrdSet) -> boolean().
+%%  Return 'true' if OrdSet is an empty set, otherwise 'false'.
+-spec is_empty(Ordset) -> boolean() when
+      Ordset :: ordset(_).
+
+is_empty(S) -> S=:=[].
+
 %% to_list(OrdSet) -> [Elem].
 %%  Return the elements in OrdSet as a list.
 
-- 
2.16.3