课程: Java Algorithms
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Hash-based structures in Java
- [Instructor] Hash structures are great tools when working with collections, sets, and data formatted as key-value pairs. In Java, there are a few different options we can use. Their differences lie in synchronization, usages of null, and whether or not duplicate values are allowed. First, there's the HashSet. The HashSet is a collection of unique items. It cannot contain duplicates, and unlike many of the other tools we've looked at previously, the order of the items is not relevant. It's great if you need to keep track of a unique set of elements. For example, let's say you're processing some purchases and you need to validate whether a vendor code is valid given a list of vendor codes. You could store the vendor codes with the HashSet and quickly check if the code is valid in 01 time. Java also has a HashMap type. This is especially useful if you need to work with key-value pairs. Let's say you have a series of employees and you need to look up information about a given employee…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。