Zuo Shen algorithm design a hash table with setAll function

Title
  : The three common operations of hash table are put, get and containsKey, and the time complexity of these three operations is O(1). Now I want to add a setAll function, which is to set the value of all records to a unified value. Please design and implement this hash table with setAll function, and the time complexity of put, get, containsKey and setAll operations is O(1).

[Basic idea]
  Add timestamp.
  1. Add a time to each record, and mark each record as appropriate to create.
  2. Set a setAll record and add a time to mark when the setAll record was created
  . 3. When querying records, if the time of a record is It is earlier than the time recorded by setAll, indicating that setAll is the latest data, and returns the value recorded by setAll. If the time of a record is later than the time recorded by setAll, the value of the record is the latest data, and the value of the record is returned

[Comment] The hash table is a key-value pair of KV, and K and V are objects. The hash table MyHashMap designed by myself must have a member variable that is a reference to the basic hash table HashMap type. For the incoming type V, first use the MyValue defined by yourself to wrap the Value layer, and increase the member variable time. MyValue<> considers the generic type to be consistent with the V type.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325855243&siteId=291194637