Hashable object introduction

xiaoxiao2021-03-06  39

When you create a Hashable object, you can specify its original capacity:

Hashtable Employees = New Hashable (53);

Hashable has many other constructor, when using internal algorithms in the dictionary, if capacity is a number of prime, its work efficiency is the highest.

Add an object to HashTable, use method add (), but hashtable.add () with two parameters, which are applications where objects are. The first parameter is a reference to the key, and the second parameter is a reference to the data. As follows:

Employeeid ID;

Employeedata Data;

Employees.Add (ID, DATA);

In order to get the data in an entry, you need to provide a button. HashTable executes an index, so you can get data,

Employeedate Data = Employees [ID];

delete,

Employees.Remove (ID);

Using the count property, you can determine how many numbers in the hash table.

INT NEMPLOYEES = EMPLOYEES.COUNT;

The more the elements of the dictionary, the larger the crash between the keys, so it is best to ensure that the dictionary is greater than the number of elements. Therefore, the HashTable will automatically reassign the memory before the dictionary is filled, increase its capacity. The scale is filled with load (LOAD)

Hashtable Employees = New hashtable (50, 0.5);

转载请注明原文地址:https://www.9cbs.com/read-62280.html

New Post(0)