The properties First
and Second give access to contents of the pair.
A triple is a data record with three elements. Like pairs, triples are immutable
values with structural equality.
Triple
nameIdPay =
new Triple(1, "Alice", 2000.0);
Assert.AreEqual(nameId.First, 1);
Assert.AreEqual(nameId.Second, "Alice");
Assert.AreEqual(nameId.Third, 2000.0);
The triple constructor takes three values as its arguments. The properties First,
Second, and Third give access to contents of the data record.
Pairs and triples work well with sets, maps, sequences, and bags. For example,
a set of pairs represents a binary relation. Binary relations occur often in systems
with dynamic relationships between entities.
10.4 Case study: revision control system
In this section we present a case study for a revision control system that uses some
of the data types introduced in the preceding sections.
A revision control system is a distributed software application that helps programmers
work together on a common source base. Each user edits a local copy of
170 Modeling Systems with Structured State
the source files in the repository. Changes made to this local copy affect the global
repository of source code only when the user commits changes. Changes are always
applied as an atomic transaction.
An important feature of a revision control system is the handling of conflicts, or
cases when two users have made simultaneous updates to the same source file.
Pages:
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239