aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/doc/src/gb_sets.xml
diff options
context:
space:
mode:
authorHans Bolinder <[email protected]>2011-05-06 15:58:09 +0200
committerHans Bolinder <[email protected]>2011-05-12 08:03:42 +0200
commit229d0d8ca88bc344bed89e46541b325c1d267996 (patch)
tree74fec344df8596c868c36cec5ac08102008cacf3 /lib/stdlib/doc/src/gb_sets.xml
parent68fe6a14539b82250373ef114d6576e74e1b8f2e (diff)
downloadotp-229d0d8ca88bc344bed89e46541b325c1d267996.tar.gz
otp-229d0d8ca88bc344bed89e46541b325c1d267996.tar.bz2
otp-229d0d8ca88bc344bed89e46541b325c1d267996.zip
r
Use Erlang specs and types for documentation
Diffstat (limited to 'lib/stdlib/doc/src/gb_sets.xml')
-rw-r--r--lib/stdlib/doc/src/gb_sets.xml288
1 files changed, 94 insertions, 194 deletions
diff --git a/lib/stdlib/doc/src/gb_sets.xml b/lib/stdlib/doc/src/gb_sets.xml
index 60d8bcbfa3..38de51322f 100644
--- a/lib/stdlib/doc/src/gb_sets.xml
+++ b/lib/stdlib/doc/src/gb_sets.xml
@@ -4,7 +4,7 @@
<erlref>
<header>
<copyright>
- <year>2001</year><year>2010</year>
+ <year>2001</year><year>2011</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
@@ -114,34 +114,32 @@
</list>
</section>
- <section>
- <title>DATA TYPES</title>
- <code type="none">
-gb_set() = a GB set</code>
- </section>
+ <datatypes>
+ <datatype>
+ <name><marker id="type-gb_set">gb_set()</marker></name>
+ <desc><p>A GB set.</p></desc>
+ </datatype>
+ <datatype>
+ <name name="iter"/>
+ <desc><p>A GB set iterator.</p></desc>
+ </datatype>
+ </datatypes>
<funcs>
<func>
- <name>add(Element, Set1) -> Set2</name>
- <name>add_element(Element, Set1) -> Set2</name>
+ <name name="add" arity="2"/>
+ <name name="add_element" arity="2"/>
<fsummary>Add a (possibly existing) element to a gb_set</fsummary>
- <type>
- <v>Element = term()</v>
- <v>Set1 = Set2 = gb_set()</v>
- </type>
<desc>
- <p>Returns a new gb_set formed from <c>Set1</c> with
- <c>Element</c> inserted. If <c>Element</c> is already an
- element in <c>Set1</c>, nothing is changed.</p>
+ <p>Returns a new gb_set formed from <c><anno>Set1</anno></c> with
+ <c><anno>Element</anno></c> inserted. If <c><anno>Element</anno></c> is already an
+ element in <c><anno>Set1</anno></c>, nothing is changed.</p>
</desc>
</func>
<func>
- <name>balance(Set1) -> Set2</name>
+ <name name="balance" arity="1"/>
<fsummary>Rebalance tree representation of a gb_set</fsummary>
- <type>
- <v>Set1 = Set2 = gb_set()</v>
- </type>
<desc>
- <p>Rebalances the tree representation of <c>Set1</c>. Note that
+ <p>Rebalances the tree representation of <c><anno>Set1</anno></c>. Note that
this is rarely necessary, but may be motivated when a large
number of elements have been deleted from the tree without
further insertions. Rebalancing could then be forced in order
@@ -150,208 +148,144 @@ gb_set() = a GB set</code>
</desc>
</func>
<func>
- <name>delete(Element, Set1) -> Set2</name>
+ <name name="delete" arity="2"/>
<fsummary>Remove an element from a gb_set</fsummary>
- <type>
- <v>Element = term()</v>
- <v>Set1 = Set2 = gb_set()</v>
- </type>
<desc>
- <p>Returns a new gb_set formed from <c>Set1</c> with
- <c>Element</c> removed. Assumes that <c>Element</c> is present
- in <c>Set1</c>.</p>
+ <p>Returns a new gb_set formed from <c><anno>Set1</anno></c> with
+ <c><anno>Element</anno></c> removed. Assumes that <c><anno>Element</anno></c> is present
+ in <c><anno>Set1</anno></c>.</p>
</desc>
</func>
<func>
- <name>delete_any(Element, Set1) -> Set2</name>
- <name>del_element(Element, Set1) -> Set2</name>
+ <name name="delete_any" arity="2"/>
+ <name name="del_element" arity="2"/>
<fsummary>Remove a (possibly non-existing) element from a gb_set</fsummary>
- <type>
- <v>Element = term()</v>
- <v>Set1 = Set2 = gb_set()</v>
- </type>
<desc>
- <p>Returns a new gb_set formed from <c>Set1</c> with
- <c>Element</c> removed. If <c>Element</c> is not an element
- in <c>Set1</c>, nothing is changed.</p>
+ <p>Returns a new gb_set formed from <c><anno>Set1</anno></c> with
+ <c><anno>Element</anno></c> removed. If <c><anno>Element</anno></c> is not an element
+ in <c><anno>Set1</anno></c>, nothing is changed.</p>
</desc>
</func>
<func>
- <name>difference(Set1, Set2) -> Set3</name>
- <name>subtract(Set1, Set2) -> Set3</name>
+ <name name="difference" arity="2"/>
+ <name name="subtract" arity="2"/>
<fsummary>Return the difference of two gb_sets</fsummary>
- <type>
- <v>Set1 = Set2 = Set3 = gb_set()</v>
- </type>
<desc>
- <p>Returns only the elements of <c>Set1</c> which are not also
- elements of <c>Set2</c>.</p>
+ <p>Returns only the elements of <c><anno>Set1</anno></c> which are not also
+ elements of <c><anno>Set2</anno></c>.</p>
</desc>
</func>
<func>
- <name>empty() -> Set</name>
- <name>new() -> Set</name>
+ <name name="empty" arity="0"/>
+ <name name="new" arity="0"/>
<fsummary>Return an empty gb_set</fsummary>
- <type>
- <v>Set = gb_set()</v>
- </type>
<desc>
<p>Returns a new empty gb_set.</p>
</desc>
</func>
<func>
- <name>filter(Pred, Set1) -> Set2</name>
+ <name name="filter" arity="2"/>
<fsummary>Filter gb_set elements</fsummary>
- <type>
- <v>Pred = fun (E) -> bool()</v>
- <v>&nbsp;E = term()</v>
- <v>Set1 = Set2 = gb_set()</v>
- </type>
<desc>
- <p>Filters elements in <c>Set1</c> using predicate function
- <c>Pred</c>.</p>
+ <p>Filters elements in <c><anno>Set1</anno></c> using predicate function
+ <c><anno>Pred</anno></c>.</p>
</desc>
</func>
<func>
- <name>fold(Function, Acc0, Set) -> Acc1</name>
+ <name name="fold" arity="3"/>
<fsummary>Fold over gb_set elements</fsummary>
- <type>
- <v>Function = fun (E, AccIn) -> AccOut</v>
- <v>Acc0 = Acc1 = AccIn = AccOut = term()</v>
- <v>&nbsp;E = term()</v>
- <v>Set = gb_set()</v>
- </type>
<desc>
- <p>Folds <c>Function</c> over every element in <c>Set</c>
+ <p>Folds <c><anno>Function</anno></c> over every element in <c><anno>Set</anno></c>
returning the final value of the accumulator.</p>
</desc>
</func>
<func>
- <name>from_list(List) -> Set</name>
+ <name name="from_list" arity="1"/>
<fsummary>Convert a list into a gb_set</fsummary>
- <type>
- <v>List = [term()]</v>
- <v>Set = gb_set()</v>
- </type>
<desc>
- <p>Returns a gb_set of the elements in <c>List</c>, where
- <c>List</c> may be unordered and contain duplicates.</p>
+ <p>Returns a gb_set of the elements in <c><anno>List</anno></c>, where
+ <c><anno>List</anno></c> may be unordered and contain duplicates.</p>
</desc>
</func>
<func>
- <name>from_ordset(List) -> Set</name>
+ <name name="from_ordset" arity="1"/>
<fsummary>Make a gb_set from an ordset list</fsummary>
- <type>
- <v>List = [term()]</v>
- <v>Set = gb_set()</v>
- </type>
<desc>
- <p>Turns an ordered-set list <c>List</c> into a gb_set. The list
+ <p>Turns an ordered-set list <c><anno>List</anno></c> into a gb_set. The list
must not contain duplicates.</p>
</desc>
</func>
<func>
- <name>insert(Element, Set1) -> Set2</name>
+ <name name="insert" arity="2"/>
<fsummary>Add a new element to a gb_set</fsummary>
- <type>
- <v>Element = term()</v>
- <v>Set1 = Set2 = gb_set()</v>
- </type>
<desc>
- <p>Returns a new gb_set formed from <c>Set1</c> with
- <c>Element</c> inserted. Assumes that <c>Element</c> is not
- present in <c>Set1</c>.</p>
+ <p>Returns a new gb_set formed from <c><anno>Set1</anno></c> with
+ <c><anno>Element</anno></c> inserted. Assumes that <c><anno>Element</anno></c> is not
+ present in <c><anno>Set1</anno></c>.</p>
</desc>
</func>
<func>
- <name>intersection(Set1, Set2) -> Set3</name>
+ <name name="intersection" arity="2"/>
<fsummary>Return the intersection of two gb_sets</fsummary>
- <type>
- <v>Set1 = Set2 = Set3 = gb_set()</v>
- </type>
<desc>
- <p>Returns the intersection of <c>Set1</c> and <c>Set2</c>.</p>
+ <p>Returns the intersection of <c><anno>Set1</anno></c> and <c><anno>Set2</anno></c>.</p>
</desc>
</func>
<func>
- <name>intersection(SetList) -> Set</name>
+ <name name="intersection" arity="1"/>
<fsummary>Return the intersection of a list of gb_sets</fsummary>
- <type>
- <v>SetList = [gb_set()]</v>
- <v>Set = gb_set()</v>
- </type>
<desc>
<p>Returns the intersection of the non-empty list of gb_sets.</p>
</desc>
</func>
<func>
- <name>is_disjoint(Set1, Set2) -> bool()</name>
+ <name name="is_disjoint" arity="2"/>
<fsummary>Check whether two gb_sets are disjoint</fsummary>
- <type>
- <v>Set1 = Set2 = gb_set()</v>
- </type>
<desc>
- <p>Returns <c>true</c> if <c>Set1</c> and
- <c>Set2</c> are disjoint (have no elements in common),
+ <p>Returns <c>true</c> if <c><anno>Set1</anno></c> and
+ <c><anno>Set2</anno></c> are disjoint (have no elements in common),
and <c>false</c> otherwise.</p>
</desc>
</func>
<func>
- <name>is_empty(Set) -> bool()</name>
+ <name name="is_empty" arity="1"/>
<fsummary>Test for empty gb_set</fsummary>
- <type>
- <v>Set = gb_set()</v>
- </type>
<desc>
- <p>Returns <c>true</c> if <c>Set</c> is an empty set, and
+ <p>Returns <c>true</c> if <c><anno>Set</anno></c> is an empty set, and
<c>false</c> otherwise.</p>
</desc>
</func>
<func>
- <name>is_member(Element, Set) -> bool()</name>
- <name>is_element(Element, Set) -> bool()</name>
+ <name name="is_member" arity="2"/>
+ <name name="is_element" arity="2"/>
<fsummary>Test for membership of a gb_set</fsummary>
- <type>
- <v>Element = term()</v>
- <v>Set = gb_set()</v>
- </type>
<desc>
- <p>Returns <c>true</c> if <c>Element</c> is an element of
- <c>Set</c>, otherwise <c>false</c>.</p>
+ <p>Returns <c>true</c> if <c><anno>Element</anno></c> is an element of
+ <c><anno>Set</anno></c>, otherwise <c>false</c>.</p>
</desc>
</func>
<func>
- <name>is_set(Term) -> bool()</name>
+ <name name="is_set" arity="1"/>
<fsummary>Test for a gb_set</fsummary>
- <type>
- <v>Term = term()</v>
- </type>
<desc>
- <p>Returns <c>true</c> if <c>Set</c> appears to be a gb_set,
+ <p>Returns <c>true</c> if <c><anno>Term</anno></c> appears to be a gb_set,
otherwise <c>false</c>.</p>
</desc>
</func>
<func>
- <name>is_subset(Set1, Set2) -> bool()</name>
+ <name name="is_subset" arity="2"/>
<fsummary>Test for subset</fsummary>
- <type>
- <v>Set1 = Set2 = gb_set()</v>
- </type>
<desc>
- <p>Returns <c>true</c> when every element of <c>Set1</c> is
- also a member of <c>Set2</c>, otherwise <c>false</c>.</p>
+ <p>Returns <c>true</c> when every element of <c><anno>Set1</anno></c> is
+ also a member of <c><anno>Set2</anno></c>, otherwise <c>false</c>.</p>
</desc>
</func>
<func>
- <name>iterator(Set) -> Iter</name>
+ <name name="iterator" arity="1"/>
<fsummary>Return an iterator for a gb_set</fsummary>
- <type>
- <v>Set = gb_set()</v>
- <v>Iter = term()</v>
- </type>
<desc>
<p>Returns an iterator that can be used for traversing the
- entries of <c>Set</c>; see <c>next/1</c>. The implementation
+ entries of <c><anno>Set</anno></c>; see <c>next/1</c>. The implementation
of this is very efficient; traversing the whole set using
<c>next/1</c> is only slightly slower than getting the list
of all elements using <c>to_list/1</c> and traversing that.
@@ -361,118 +295,84 @@ gb_set() = a GB set</code>
</desc>
</func>
<func>
- <name>largest(Set) -> term()</name>
+ <name name="largest" arity="1"/>
<fsummary>Return largest element</fsummary>
- <type>
- <v>Set = gb_set()</v>
- </type>
<desc>
- <p>Returns the largest element in <c>Set</c>. Assumes that
- <c>Set</c> is nonempty.</p>
+ <p>Returns the largest element in <c><anno>Set</anno></c>. Assumes that
+ <c><anno>Set</anno></c> is nonempty.</p>
</desc>
</func>
<func>
- <name>next(Iter1) -> {Element, Iter2} | none</name>
+ <name name="next" arity="1"/>
<fsummary>Traverse a gb_set with an iterator</fsummary>
- <type>
- <v>Iter1 = Iter2 = Element = term()</v>
- </type>
<desc>
- <p>Returns <c>{Element, Iter2}</c> where <c>Element</c> is the
- smallest element referred to by the iterator <c>Iter1</c>,
- and <c>Iter2</c> is the new iterator to be used for
+ <p>Returns <c>{<anno>Element</anno>, <anno>Iter2</anno>}</c> where <c><anno>Element</anno></c> is the
+ smallest element referred to by the iterator <c><anno>Iter1</anno></c>,
+ and <c><anno>Iter2</anno></c> is the new iterator to be used for
traversing the remaining elements, or the atom <c>none</c> if
no elements remain.</p>
</desc>
</func>
<func>
- <name>singleton(Element) -> gb_set()</name>
+ <name name="singleton" arity="1"/>
<fsummary>Return a gb_set with one element</fsummary>
- <type>
- <v>Element = term()</v>
- </type>
<desc>
- <p>Returns a gb_set containing only the element <c>Element</c>.</p>
+ <p>Returns a gb_set containing only the element <c><anno>Element</anno></c>.</p>
</desc>
</func>
<func>
- <name>size(Set) -> int()</name>
+ <name name="size" arity="1"/>
<fsummary>Return the number of elements in a gb_set</fsummary>
- <type>
- <v>Set = gb_set()</v>
- </type>
<desc>
- <p>Returns the number of elements in <c>Set</c>.</p>
+ <p>Returns the number of elements in <c><anno>Set</anno></c>.</p>
</desc>
</func>
<func>
- <name>smallest(Set) -> term()</name>
+ <name name="smallest" arity="1"/>
<fsummary>Return smallest element</fsummary>
- <type>
- <v>Set = gb_set()</v>
- </type>
<desc>
- <p>Returns the smallest element in <c>Set</c>. Assumes that
- <c>Set</c> is nonempty.</p>
+ <p>Returns the smallest element in <c><anno>Set</anno></c>. Assumes that
+ <c><anno>Set</anno></c> is nonempty.</p>
</desc>
</func>
<func>
- <name>take_largest(Set1) -> {Element, Set2}</name>
+ <name name="take_largest" arity="1"/>
<fsummary>Extract largest element</fsummary>
- <type>
- <v>Set1 = Set2 = gb_set()</v>
- <v>Element = term()</v>
- </type>
<desc>
- <p>Returns <c>{Element, Set2}</c>, where <c>Element</c> is the
- largest element in <c>Set1</c>, and <c>Set2</c> is this set
- with <c>Element</c> deleted. Assumes that <c>Set1</c> is
+ <p>Returns <c>{<anno>Element</anno>, <anno>Set2</anno>}</c>, where <c><anno>Element</anno></c> is the
+ largest element in <c><anno>Set1</anno></c>, and <c><anno>Set2</anno></c> is this set
+ with <c><anno>Element</anno></c> deleted. Assumes that <c><anno>Set1</anno></c> is
nonempty.</p>
</desc>
</func>
<func>
- <name>take_smallest(Set1) -> {Element, Set2}</name>
+ <name name="take_smallest" arity="1"/>
<fsummary>Extract smallest element</fsummary>
- <type>
- <v>Set1 = Set2 = gb_set()</v>
- <v>Element = term()</v>
- </type>
<desc>
- <p>Returns <c>{Element, Set2}</c>, where <c>Element</c> is the
- smallest element in <c>Set1</c>, and <c>Set2</c> is this set
- with <c>Element</c> deleted. Assumes that <c>Set1</c> is
+ <p>Returns <c>{<anno>Element</anno>, <anno>Set2</anno>}</c>, where <c><anno>Element</anno></c> is the
+ smallest element in <c><anno>Set1</anno></c>, and <c><anno>Set2</anno></c> is this set
+ with <c><anno>Element</anno></c> deleted. Assumes that <c><anno>Set1</anno></c> is
nonempty.</p>
</desc>
</func>
<func>
- <name>to_list(Set) -> List</name>
+ <name name="to_list" arity="1"/>
<fsummary>Convert a gb_set into a list</fsummary>
- <type>
- <v>Set = gb_set()</v>
- <v>List = [term()]</v>
- </type>
<desc>
- <p>Returns the elements of <c>Set</c> as a list.</p>
+ <p>Returns the elements of <c><anno>Set</anno></c> as a list.</p>
</desc>
</func>
<func>
- <name>union(Set1, Set2) -> Set3</name>
+ <name name="union" arity="2"/>
<fsummary>Return the union of two gb_sets</fsummary>
- <type>
- <v>Set1 = Set2 = Set3 = gb_set()</v>
- </type>
<desc>
- <p>Returns the merged (union) gb_set of <c>Set1</c> and
- <c>Set2</c>.</p>
+ <p>Returns the merged (union) gb_set of <c><anno>Set1</anno></c> and
+ <c><anno>Set2</anno></c>.</p>
</desc>
</func>
<func>
- <name>union(SetList) -> Set</name>
+ <name name="union" arity="1"/>
<fsummary>Return the union of a list of gb_sets</fsummary>
- <type>
- <v>SetList = [gb_set()]</v>
- <v>Set = gb_set()</v>
- </type>
<desc>
<p>Returns the merged (union) gb_set of the list of gb_sets.</p>
</desc>