The Data Structures Library in Java

JDSL Explorations


Data Accessors

author(s)dateJDSL version
Ulrik Brandes 07/99 2.0

Summary: JDSL algorithms expect and provide attribute data in one of four basic forms of organization,

where the last one is really an abstraction of the other three. Method based access to attribute data adds flexibility to an algorithm, since it does not prescribed one of the other three means of organization, but it requires that the algorithm class be subclassed in order to be useful. A different design, originally proposed by Dietmar Kühl and Karsten Weihe: `Data Access Templates', C++ Report 9(7):15,18-21, 1997, requires data to be accessed via classes implementing an intermediate interface, thus standardizing access while leaving open its implementation. To illustrate the concept, JDSL-specific realizations are given below.


The elements of data structures input in or output by an algorithm are often parameterized with attributes. There are several ways to organize the representation of these attributesd with respect to the data structure. For example, the attributes can be stored in a field of the record representing the element, or they can be stored in a separate data structure that is indexed with the elements.

As of version 2.0, JDSL utilizes three different forms of representation for attributes. They can either be stored as decorations of the elements in the data structure, stored in hashtables, or stored as the one piece of data that an Accessor returns. JDSL algorithms often expect input parameters as return values of template methods and return results in the form of decorations. This makes subclassing of algorithms a prerequisite and complicates the use of output as input for other algorithms.

Data accessors abstract the access of attributes into a standardized interface. Algorithms expecting input and providing output via data accessors need not be modified to accomodate different forms of attribute representation. Rather, the small data accessor class that is acting as a mediator between algorithm and data is customized.

Below, an example realization of this concept in the context of JDSL is provided. It consists of interfaces for data access and classes implementing these interface so as to abstract away the standard form of attribute representation in JDSL. Note that an implementation of the InspectableAttribute interface may just as well give access to non-materialized attributes.

See the alternative implementation of Dijkstra's algorithm for an example application.