Current area: HOME -> Java -> Data Structures Articles
Data Structures
Data Structures in Java: Part 1, Getting Started
This article introduces you to the Java Collections Framework. Once you learn how to use it, you'll never need to reinvent common data structures and algorithms again.
Data Structures in Java: Part 14, The Comparator Interface, Part 6
This article shows you how to use a Comparator created by the reverseOrder method of the Collections class to sort a list into reverse natural order. He also shows you how to use the reverse method of the Collections class to reverse the order of the elements in a list.
Data Structures in Java: Part 15, The toArray Method, Part 1
This article shows you how to use the simpler version of the overloaded toArray method that is declared in the Collection interface. He also explains why you need to exercise care when using the elements stored in the resulting array to avoid corrupting the state of the objects referred to by the elements in the collection.
Data Structures in Java: Part 3, Purpose of Framework Interfaces
There are six core interfaces in the Collections Framework. Each interface declares several methods and provides a contract that applies to each declared method. The method declarations and their associated contracts specify the general behavior of ...
Data Structures in Java: Part 6
This article shows you that all concrete implementations in the Java Collections Framework (JDK 1.3) implement a subinterface of the Collection interface.
Faster List Iteration with RandomAccess Interface
Java SDK version 1.4, due out later this year, introduces a new
java.util.RandomAccess interface that has no methods. What is
the purpose of this interface?
Optimizing Hash Functions For a Perfect Map
Maps that are hash tables are normally implemented using a hash function which maps a data item (the key) into an indexing table. The hash function takes the key and uses some algorithm to convert it to an index value into an array.
Secure type-safe collections
In this article, Piet Jonas demonstrates a framework that overcomes the standard Java Collections Framework's main problem: its containers lack the ability to restrict themselves to storing objects of a specific type.
StringBuffer versus String
Reggie illuminates the underlying performance impact of using the StringBuffer and String classes when performing concatenations.
The Hashbelt Data Structure
In the first article in this series, I explained why it is sometimes necessary to expire data, and discussed the standard approaches for doing so. This article focuses on a particular algorithm for data expiration that I have taken to calling a "hashbelt." (The name is a combination of "hashmap" and "conveyor belt.") Hashbelts are a generic data structure that can be easily adapted to a wide variety of problems involving time-sensitive data. They are easy to use, simple to extend, and quite efficient.
The Performance of Java's Lists
In this article I'll take a look at the performance differences between the LinkedList implementation and the Vector/ArrayList implementations.
The WeakHashMap Class
WeakHashMap is a type of Map which differs from other Maps in more than just having a different implementation. WeakHashMap uses weak references to hold its keys, making it one of the few classes able to respond to the fluctuating memory requirements of the JVM. This can make WeakHashMap unpredictable at times, unless you know exactly what you are doing with it. In the following sections I examine how best to use WeakHashMap, and why WeakHashMap behaves the way it does.