Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@

/**
* Write a description of class MostFrequentWordHashMap.
*
* 1. Generate an Hashmap of string and integers
* 2. Generate an input of strings
* 1.for items in the input
* a. if the hashmap does not contain the item
* b.add it and increment the value
* c. else
* d. increment the value
*
* @author (Aymar S. NAHUM)
* @version (10/20/2024)
*
*/
import java.util.HashMap;
Expand All @@ -30,24 +35,28 @@ public MostFrequentWordHashMap()

/**
* An example of a method - replace this comment with your own
*
* @param y a sample parameter for a method
* @return the sum of x and y
*/

public static HashMap<String, Integer> mapUniqueMethod(ArrayList<String> input)
{
// The dynamic compiler often increments the outcome
// A solution is to generate a clear function
// uniqueMap.clear()
public static void clearMap(ArrayList<String> input){

//uniqueMap.clear();
//The compiler is dynamic and increments the outcome at each iteration
//A workaround can be to loop the clear function

for(int i = 0 ; i < input.size() ; i = i + 1)
{
uniqueMap.clear();

for(int i = 0 ; i < input.size(); i = i + 1){
uniqueMap.put( null, null);
}

}

public static HashMap<String, Integer> mapUniqueMethod(ArrayList<String> input)
{


//To avoid dynamic issues, clear the hashMap first.
//Can't reproduce
uniqueMap.remove(uniqueMap.get(null));
for(int i = 0 ; i < input.size() ; i = i + 1)
{
if(!uniqueMap.containsKey(input.get(i))){
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@

/**
* Write a description of class testUniqueWordMap here.
* Write a description of class MostFrequentWordHashMapTest.
*
* @author (your name)
* @version (a version number or a date)
* @author (Aymar S. NAHUM)
* @version (10/20/2024)
*/
import java.util.ArrayList;

public class MostFrequentWordHashMapTest
{
public class MostFrequentWordHashMapTest{


// instance variables - replace the example below with your own
public static ArrayList<String> in = new ArrayList<String>();

Expand Down Expand Up @@ -46,6 +47,7 @@ public static void testUniqueHashMethod()

MostFrequentWordHashMap MostFrequentWordHashMap = new MostFrequentWordHashMap();
//MostFrequentWordHashMap.mapUniqueMethod(in);
MostFrequentWordHashMap.clearMap(in);
MostFrequentWordHashMap.findMaxMethod(MostFrequentWordHashMap.mapUniqueMethod(in));
}
}