Chapter 2. Reference implementation

 

This chapter covers

  • Using standard collections
  • Creating diagrams to illustrate a software design
  • Expressing performance in big-O notation
  • Estimating the memory footprint of a class

In this chapter, you’ll examine a version of the Container class that strikes a good balance between different qualities, such as clarity, efficiency, and memory usage.

As you recall from section 1.7, I made the assumption that storing and maintaining the set of indirect connections between containers would suffice. In practice, you do this by equipping each container with a reference to the collection of containers directly or indirectly connected to it, called its group. Being familiar with the Java Collections Framework (JCF) (see sidebar), let’s go hunting for the best class to represent one of these groups.

Java Collections Framework

Most standard collections were introduced in Java 1.2 and were heavily redesigned for the 1.5 release (later renamed Java 5) to take advantage of the newly introduced generics. The resulting API is called the JCF and is one of the crown jewels of the Java ecosystem. It comprises approximately 25 classes and interfaces, providing common data structures such as linked lists, hash tables, and balanced trees, as well as concurrency-oriented facilities.

2.1. The code    [Reference]

 
 

2.2. Memory requirements

 
 
 
 

2.3. Time complexity

 

2.4. Applying what you learned

 
 

Summary

 
 
 

Answers to quizzes and exercises

 
 
 

Further reading

 
 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest