IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Opened 22 years ago

Closed 22 years ago

Last modified 21 years ago

#249 closed defect (fixed)

psList changes made during implementation

Reported by: robert.desonia@… 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

Change History (1)

comment:1 by Paul Price, 22 years ago

Resolution: fixed
Status: newclosed

OK, thanks. Here's the source in the updated SDRS, to check:

\begin{verbatim}
typedef struct {

unsigned int size; /< number of elements on list
psListElem *head;
/< first element on list (may be NULL)
psListElem *tail; /< last element on list (may be NULL)
psArray *iterators;
/< array of psListIterator: iteration

cursors

pthread_mutex_t lock; /< mutex to lock a node during changes

} 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 {

psList *list; /< List iterator works on
psListElem *cursor;
/< The current iterator cursor
bool offEnd; /< Is the iterator off the end?
int index;
/< Index of iterator, to assist performance

} 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).

Note: See TracTickets for help on using tickets.