#249 closed defect (fixed)
psList changes made during implementation
| Reported by: | Owned by: | Paul Price | |
|---|---|---|---|
| Priority: | high | Milestone: | |
| Component: | PSLib SDRS | Version: | unspecified |
| Severity: | minor | Keywords: | |
| Cc: |
Description
In implementation of psList, I found the nIter attribute in the psList struct,
as found in the documentation, not needed as the iterators are stored in an
psArray, which has a size attribute already. I, hence, removed 'nIter' from the
struct. Also, renamed the 'iter' attribute to 'iterators' to convey that
multiple iterators where contained in the array.
In the psListIterator struct, I removed the 'num' attribute as it served no
purpose. I could have used it to remove the iterator from the iterators array
in psList, but the psArrayRemove method makes it simple enough to remove the
iterator without it and I suspect that the number of iterators for a given list
is not large enough to worry about any searching inefficiencies. I added,
however, an 'index' attribute to help performance when using numerical locations
(i.e., when the user works through an array by location number). On an add or
remove, these indices are updated as required.
-rdd

OK, thanks. Here's the source in the updated SDRS, to check:
\begin{verbatim}
typedef struct {
cursors
} psList;
\end{verbatim}
%
The type \code{psList} represents the container of the list. It has a
pointer to the first element in the linked list (\code{head}), a
pointer to the last element in the list (\code{tail}), an array of
iteration cursors, (\code{iterators}), and an entry to define the
number of elements in the list (\code{size}). The \code{lock} should
be applied during changes to the list to maintain thread safety.
Iteration on the list shall be achieved by means of a list iterator
type:
\begin{verbatim}
typedef struct {
} psListIterator;
\end{verbatim}
The \code{psListIterator} keeps track of which list element the
iterator \code{cursor} is currently pointing at. \code{index} is the
index of the list iterator, which is used to assist performance when
using numerical locations. The boolean member, \code{offEnd},
indicates whether the iterator has progressed off the end of the list
(i.e., beyond the last item).