customersetaccess.java
来自「国外的数据结构与算法分析用书」· Java 代码 · 共 37 行
JAVA
37 行
package Sets;
import People.Customer;
import dslib.dictionary.PKeyedBasicDictUos;
import dslib.dictionary.arrayed.ArrayedPKeyedBasicDictUos;
/** Provides access to the dictionary containing the customers. */
public class CustomerSetAccess
{
/** The dictionary for customers. */
private static PKeyedBasicDictUos dictionary;
/** Returns the dictionary that maps names to customers.
Analysis: Time = O(1) */
public static PKeyedBasicDictUos dictionary()
{
return dictionary;
}
/** Display all the information of customer
Analysis: Time = O(1) */
public static void displayCustomer()
{
System.out.println("The customer's name is: Elvis Presley");
System.out.println("The customer's name is: Wile E. Coyote\n");
}
/** Initializes the customer dictionary.
Analysis: Time = O(1) */
static
{
dictionary = new ArrayedPKeyedBasicDictUos(10);
dictionary.insert("Elvis Presley", new Customer("Elvis Presley"));
dictionary.insert("Wile E. Coyote", new Customer("Wile E. Coyote"));
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?