% Copyright The Numerical Algorithms Group Limited 1992-94. All rights reserved.
% !! DO NOT MODIFY THIS FILE BY HAND !! Created by ht.awk.
\newcommand{\SparseTableXmpTitle}{SparseTable}
\newcommand{\SparseTableXmpNumber}{9.77}
%
% =====================================================================
\begin{page}{SparseTableXmpPage}{9.77 SparseTable}
% =====================================================================
\beginscroll

%
%
%
%
%


%
The \spadtype{SparseTable} domain provides a general purpose
table type with default entries.
\xtc{
Here we create a table to save strings under integer keys.
The value \spad{"Try again!"} is returned if no other value has been
stored for a key.
}{
\spadpaste{t: SparseTable(Integer, String, "Try again!") := table() \bound{t}}
}
\xtc{
Entries can be stored in the table.
}{
\spadpaste{t.3 := "Number three" \free{t}\bound{t1}}
}
\xtc{
}{
\spadpaste{t.4 := "Number four" \free{t}\bound{t2}}
}
\xtc{
These values can be retrieved as usual, but if a look up fails
the default entry will be returned.
}{
\spadpaste{t.3 \free{t1}}
}
\xtc{
}{
\spadpaste{t.2 \free{t}}
}
\xtc{
To see which values are explicitly stored, the
\spadfunFrom{keys}{SparseTable} and \spadfunFrom{entries}{SparseTable}
functions can be used.
}{
\spadpaste{keys t \free{t1 t2}}
}
\xtc{
}{
\spadpaste{entries t \free{t1 t2}}
}
If a specific table representation
is required, the \spadtype{GeneralSparseTable} constructor should be used.
The domain \spadtype{SparseTable(K, E, dflt)} is equivalent to
\spadtype{GeneralSparseTable(K,E, Table(K,E), dflt)}.
%-% \HDexptypeindex{GeneralSparseTable}{SparseTableXmpPage}{9.77}{SparseTable}
For more information, see
\downlink{`Table'}{TableXmpPage}\ignore{Table} and
\downlink{`GeneralSparseTable'}{GeneralSparseTableXmpPage}\ignore{GeneralSparseTable}.
\showBlurb{SparseTable}
\endscroll
\autobuttons
\end{page}
%
