File(s) not publicly available

Flexible selection of output format for sets in Java collections : algorithms and their complexity and reusability

journal contribution
posted on 06.12.2017, 00:00 by Wanwu GuoWanwu Guo
Set, a collection of distinct values, is widely used in many applications. There are three applicable set classes included in the Java Collections. TreeSet produces a sorted output in ascending order whereas HashSet provides an output with random order. LinkedHashSet, a subclass of HashSet, produces an output in insertion order, but does not support the sorted output. Three algorithms are proposed in this paper to modify the existing set classes in the Java Collections so that they can provide multiple output formats for users to select from. The algorithm at application-level does not change the current configurations of the set classes, but it offers little reusability. The algorithm at method level introduces an internal method for producing sorted output into the LinkedHashTable class, in addition to its default output in insertion order. This can be achieved without change to other configurations of the class. If this method is placed in the HashSet class, users can freely choose their preferred output format from random order, insertion order, or ascending order. The algorithm at class level proposes a new LinkedTreeSet class that is implemented using both a balanced BST and a doubly linked list. The basic operations of this class may be slightly slower than that in the TreeSet class.

Funding

Category 1 - Australian Competitive Grants (this includes ARC, NHMRC)

History

Volume

6

Issue

2

Start Page

309

End Page

315

Number of Pages

7

ISSN

1109-2769

Location

Athens, Greece

Publisher

World Scientific and Engineering Academy and Society (WSEAS)

Language

en-aus

Peer Reviewed

Yes

Open Access

No

External Author Affiliations

Edith Cowan University;

Era Eligible

Yes

Journal

WSEAS transactions on mathematics.