From 6c3265b86582d4848e1c77efee3a649a137694d6 Mon Sep 17 00:00:00 2001
From: Sverker Eriksson
Date: Fri, 5 May 2017 14:51:58 +0200
Subject: stdlib: Add examples for ets:select_replace docs
---
lib/stdlib/doc/src/ets.xml | 36 ++++++++++++++++++++++++++++--------
1 file changed, 28 insertions(+), 8 deletions(-)
(limited to 'lib/stdlib/doc/src')
diff --git a/lib/stdlib/doc/src/ets.xml b/lib/stdlib/doc/src/ets.xml
index d1ec176f81..62e97218cd 100644
--- a/lib/stdlib/doc/src/ets.xml
+++ b/lib/stdlib/doc/src/ets.xml
@@ -1495,17 +1495,37 @@ is_integer(X), is_integer(Y), X + Y < 4711]]>
Match and replace objects atomically in an ETS table
Matches the objects in the table Tab using a
- match specification. If
- an object is matched, the existing object is replaced with
- the match specification result, which must retain
- the original key or the operation will fail with badarg.
+ match specification. For each
+ matched object, the existing object is replaced with
+ the match specification result.
+
The match-and-replace operation for each individual object is guaranteed to be
+ atomic and isolated. The
+ select_replace table iteration as a whole, like all other select functions,
+ does not give such guarantees.
+
The match specifiction must be guaranteed to retain the key
+ of any matched object. If not, select_replace will fail with badarg
+ without updating any objects.
For the moment, due to performance and semantic constraints,
tables of type bag are not yet supported.
The function returns the total number of replaced objects.
-
-
The match/replacement operation atomicity scope is limited
- to each individual object.
-
+
Example
+
For all 2-tuples with a list in second position, add atom 'marker' first in the list: