From 959f244cd2fd0d96a8b5200ce39c86eb7071ba36 Mon Sep 17 00:00:00 2001 From: Yusuf Taiwo Hassan Date: Sat, 3 Sep 2022 21:37:29 +0100 Subject: [PATCH] Doc update --- ANSWERS.md | 2 +- storage/memory.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ANSWERS.md b/ANSWERS.md index 0c29f77..f82338e 100644 --- a/ANSWERS.md +++ b/ANSWERS.md @@ -18,7 +18,7 @@ How does your code work? ------- The most important part of the codebase is the "Storage" implementation. The "Storage" consists of two storage variables or mechanism. - *`IpAddressTallyMap`*: A hashtable for mapping an item (IP address) to a count(number). -- *`FrequencyLookupTable`*: An array whose index is the frequency of occurrence of items and the value, the collection of such item. To ensure an efficient search, insert and delete operation, the collection is modelled as a hashtable with a runtime complexity of an amortized `O(1)`. +- *`FrequencyLookupTable`*: An array whose index is the frequency of occurrence of items and the value, a collection of such item. To ensure an efficient search, insert and delete operation, the collection is modelled as a hashtable with a runtime complexity of an amortized `O(1)`. The methods of the "Storage" implementation are enumerated as follows. - *`Truncate`*: This properly reinitialized the storage variables. A dummy hashmap is inserted at index 0 of *`FrequencyLookupTable`* because there should be no values there. diff --git a/storage/memory.go b/storage/memory.go index b139533..be7efcf 100644 --- a/storage/memory.go +++ b/storage/memory.go @@ -6,6 +6,9 @@ var emptyStruct struct{} // A DefaultStorage defines a default Storage interface. // This is the starting point of extending the library to work with other storage. type DefaultStorage struct { + // IpAddressTallyMap is a hashtable for mapping an item to a count. + // FrequencyLookupTable is an array whose index is the frequency of + // occurrence of items and the value, a collection of such item. IpAddressTallyMap map[string]int FrequencyLookupTable []map[string]struct{} }