#!/usr/bin/perl
use warnings;
use strict;
use lib 'Hash';
use Hash qw( ADD DELETE SEARCH COUNT FIRST NEXT RESET );

# --- getting random words ---
my $n = 1e5;   # number of things to put in the collection.
my $word_file = 'usr_share_dict_words';
print "Generating a random list of $n words...\n";
open(WORDS,'<',$word_file) or die "Oops - couldn't open word file";
my $word;
my @words;
my $count = $n;
while ($count>0){
  chomp($word = <WORDS>);
  push @words, $word;
  $count--;
}
my @randomized_words;
while (@words){
  my $rand = int rand scalar @words;
  push @randomized_words, splice(@words, $rand, 1);
}
print "done.\n";
#print " @randomized_words \n";

# --- benchmarks ----

ADD $_ for @randomized_words;
print "There are " , COUNT(), " things in the collection. \n";
