-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHashExample.java
40 lines (39 loc) · 932 Bytes
/
HashExample.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**
* @file HashExample.java
* Examlpe implementtion of Hashing.java
*
* @author Paul Gibbons
* @date Created: Spring 2014
*/
import java.util.Random;
public class HashExample
{
public static void main(String[]args)
{
Random rng = new Random();
Hashing example = new Hashing(61);
String[] toCheck = new String[3];
for (int i=5; i<=7; i++) //words added will be of length 5 to 7
{
for (int j=0; j<200; j++) //200 words of each length
{
String name = "";
int value = (rng.nextInt(10000)+1) ;// values will range from 1 to 10000
for (int k=0; k<i; k++)
{
char c = (char) (rng.nextInt(26)+97); // all lowercase letters from a to z
name += c;
}
example.set(name, value);
if (j==150)
{
toCheck[i-5] = name;
}
}
}
for (int i=0; i<toCheck.length; i++)
{
System.out.println("Name: " + toCheck[i] + ", Value: "+ example.getValue(toCheck[i]));
}
}
}