Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
more generics, bugfixes for wrong cast
orbiter9d8b17188a90
diff --git a/source/de/anomic/index/indexCachedRI.java b/source/de/anomic/index/indexCachedRI.javaindex 3579ea934..99db70880 100644--- a/source/de/anomic/index/indexCachedRI.java+++ b/source/de/anomic/index/indexCachedRI.java@@ -116,7 +116,7 @@ public class indexCachedRI implements indexRI {if (count > 5000) count = 5000;busyCacheFlush = true;String wordHash;- ArrayList containerList = new ArrayList();+ ArrayList<indexContainer> containerList = new ArrayList<indexContainer>();synchronized (this) {for (int i = 0; i < count; i++) { // possible position of outOfMemoryError ?if (ram.size() == 0) break;@@ -140,7 +140,7 @@ public class indexCachedRI implements indexRI {return false;}- public indexContainer getContainer(String wordHash, Set urlselection) {+ public indexContainer getContainer(String wordHash, Set<String> urlselection) {// get from cacheindexContainer container = riExtern.getContainer(wordHash, urlselection);if (container == null) {@@ -158,23 +158,23 @@ public class indexCachedRI implements indexRI {return container;}- public Map getContainers(Set wordHashes, Set urlselection, boolean interruptIfEmpty) {+ public Map<String, indexContainer> getContainers(Set<String> wordHashes, Set<String> urlselection, boolean interruptIfEmpty) {// return map of wordhash:indexContainer// retrieve entities that belong to the hashes- HashMap containers = new HashMap();+ HashMap<String, indexContainer> containers = new HashMap<String, indexContainer>();String singleHash;indexContainer singleContainer;- Iterator i = wordHashes.iterator();+ Iterator<String> i = wordHashes.iterator();while (i.hasNext()) {// get next word hash:- singleHash = (String) i.next();+ singleHash = i.next();// retrieve indexsingleContainer = getContainer(singleHash, urlselection);// check result- if (((singleContainer == null) || (singleContainer.size() == 0)) && (interruptIfEmpty)) return new HashMap();+ if (((singleContainer == null) || (singleContainer.size() == 0)) && (interruptIfEmpty)) return new HashMap<String, indexContainer>();containers.put(singleHash, singleContainer);}@@ -215,7 +215,7 @@ public class indexCachedRI implements indexRI {return removed;}- public int removeEntries(String wordHash, Set urlHashes) {+ public int removeEntries(String wordHash, Set<String> urlHashes) {int removed = 0;removed += riIntern.removeEntries(wordHash, urlHashes);removed += riExtern.removeEntries(wordHash, urlHashes);@@ -223,7 +223,7 @@ public class indexCachedRI implements indexRI {return removed;}- public String removeEntriesExpl(String wordHash, Set urlHashes) {+ public String removeEntriesExpl(String wordHash, Set<String> urlHashes) {String removed = "";removed += riIntern.removeEntries(wordHash, urlHashes) + ", ";removed += riExtern.removeEntries(wordHash, urlHashes) + ", ";@@ -231,17 +231,17 @@ public class indexCachedRI implements indexRI {return removed;}- public TreeSet indexContainerSet(String startHash, boolean ramOnly, boolean rot, int count) {+ public TreeSet<indexContainer> indexContainerSet(String startHash, boolean ramOnly, boolean rot, int count) {// creates a set of indexContainers// this does not use the dhtInCachekelondroOrder containerOrder = new indexContainerOrder((kelondroOrder) indexOrder.clone());containerOrder.rotate(startHash.getBytes());- TreeSet containers = new TreeSet(containerOrder);- Iterator i = wordContainers(startHash, ramOnly, rot);+ TreeSet<indexContainer> containers = new TreeSet<indexContainer>(containerOrder);+ Iterator<indexContainer> i = wordContainers(startHash, ramOnly, rot);if (ramOnly) count = Math.min(riExtern.size(), count);indexContainer container;while ((count > 0) && (i.hasNext())) {- container = (indexContainer) i.next();+ container = i.next();if ((container != null) && (container.size() > 0)) {containers.add(container);count--;@@ -250,12 +250,12 @@ public class indexCachedRI implements indexRI {return containers;}- public kelondroCloneableIterator wordContainers(String startHash, boolean rot) {+ public kelondroCloneableIterator<indexContainer> wordContainers(String startHash, boolean rot) {// returns an iteration of indexContainersreturn wordContainers(startHash, false, rot);}- public kelondroCloneableIterator wordContainers(String startHash, boolean ramOnly, boolean rot) {+ public kelondroCloneableIterator<indexContainer> wordContainers(String startHash, boolean ramOnly, boolean rot) {kelondroCloneableIterator i;if (ramOnly) {i = riExtern.wordContainers(startHash, false);@@ -268,7 +268,7 @@ public class indexCachedRI implements indexRI {true);}if (rot) {- return new kelondroRotateIterator(i, new String(kelondroBase64Order.zero(startHash.length())));+ return new kelondroRotateIterator<indexContainer>(i, new String(kelondroBase64Order.zero(startHash.length())));} else {return i;}diff --git a/source/de/anomic/index/indexCollectionRI.java b/source/de/anomic/index/indexCollectionRI.javaindex fa4107f20..0b9d59033 100644--- a/source/de/anomic/index/indexCollectionRI.java+++ b/source/de/anomic/index/indexCollectionRI.java@@ -85,13 +85,13 @@ public class indexCollectionRI implements indexRI {return 100 * 1024 /* overhead here */ + collectionIndex.minMem();}- public synchronized kelondroCloneableIterator wordContainers(String startWordHash, boolean rot) {+ public synchronized kelondroCloneableIterator<indexContainer> wordContainers(String startWordHash, boolean rot) {return new wordContainersIterator(startWordHash, rot);}- public class wordContainersIterator implements kelondroCloneableIterator {+ public class wordContainersIterator implements kelondroCloneableIterator<indexContainer> {- private Iterator wci;+ private Iterator<Object[]> wci;private boolean rot;public wordContainersIterator(String startWordHash, boolean rot) {@@ -107,7 +107,7 @@ public class indexCollectionRI implements indexRI {return wci.hasNext();}- public Object next() {+ public indexContainer next() {Object[] oo = (Object[]) wci.next();if (oo == null) return null;byte[] key = (byte[]) oo[0];@@ -130,7 +130,7 @@ public class indexCollectionRI implements indexRI {}}- public indexContainer getContainer(String wordHash, Set urlselection) {+ public indexContainer getContainer(String wordHash, Set<String> urlselection) {try {kelondroRowSet collection = collectionIndex.get(wordHash.getBytes());if (collection != null) collection.select(urlselection);@@ -152,12 +152,12 @@ public class indexCollectionRI implements indexRI {}public boolean removeEntry(String wordHash, String urlHash) {- HashSet hs = new HashSet();- hs.add(urlHash.getBytes());+ HashSet<String> hs = new HashSet<String>();+ hs.add(urlHash);return removeEntries(wordHash, hs) == 1;}- public int removeEntries(String wordHash, Set urlHashes) {+ public int removeEntries(String wordHash, Set<String> urlHashes) {try {return collectionIndex.remove(wordHash.getBytes(), urlHashes);} catch (kelondroOutOfLimitsException e) {@@ -179,7 +179,7 @@ public class indexCollectionRI implements indexRI {}}- public void addMultipleEntries(List /*of indexContainer*/ containerList) {+ public void addMultipleEntries(List<indexContainer> containerList) {try {//for (int i = 0; i < containerList.size(); i++) collectionIndex.merge((indexContainer) containerList.get(i));collectionIndex.mergeMultiple(containerList);diff --git a/source/de/anomic/index/indexContainer.java b/source/de/anomic/index/indexContainer.javaindex 0a941bca4..d10c2ec3b 100644--- a/source/de/anomic/index/indexContainer.java+++ b/source/de/anomic/index/indexContainer.java@@ -131,7 +131,7 @@ public class indexContainer extends kelondroRowSet {if (c == null) return 0;int x = 0;synchronized (c) {- Iterator i = c.entries();+ Iterator<indexRWIRowEntry> i = c.entries();while (i.hasNext()) {try {if (putRecent((indexRWIEntry) i.next())) x++;@@ -195,7 +195,7 @@ public class indexContainer extends kelondroRowSet {public static Method containerMergeMethod = null;static {try {- Class c = Class.forName("de.anomic.index.indexContainer");+ Class<?> c = Class.forName("de.anomic.index.indexContainer");containerMergeMethod = c.getMethod("mergeUnique", new Class[]{Object.class, Object.class});} catch (SecurityException e) {System.out.println("Error while initializing containerMerge.SecurityException: " + e.getMessage());@@ -210,8 +210,8 @@ public class indexContainer extends kelondroRowSet {}public static indexContainer joinExcludeContainers(- Collection includeContainers,- Collection excludeContainers,+ Collection<indexContainer> includeContainers,+ Collection<indexContainer> excludeContainers,int maxDistance) {// join a search result and return the joincount (number of pages after join)@@ -226,12 +226,12 @@ public class indexContainer extends kelondroRowSet {return rcLocal;}- public static indexContainer joinContainers(Collection containers, int maxDistance) {+ public static indexContainer joinContainers(Collection<indexContainer> containers, int maxDistance) {// order entities by their size- TreeMap map = new TreeMap();+ TreeMap<Long, indexContainer> map = new TreeMap<Long, indexContainer>();indexContainer singleContainer;- Iterator i = containers.iterator();+ Iterator<indexContainer> i = containers.iterator();int count = 0;while (i.hasNext()) {// get next entity:@@ -268,12 +268,12 @@ public class indexContainer extends kelondroRowSet {return searchResult;}- public static indexContainer excludeContainers(indexContainer pivot, Collection containers) {+ public static indexContainer excludeContainers(indexContainer pivot, Collection<indexContainer> containers) {// check if there is any resultif ((containers == null) || (containers.size() == 0)) return pivot; // no result, nothing found- Iterator i = containers.iterator();+ Iterator<indexContainer> i = containers.iterator();while (i.hasNext()) {pivot = excludeDestructive(pivot, (indexContainer) i.next());if ((pivot == null) || (pivot.size() == 0)) return null;@@ -316,7 +316,7 @@ public class indexContainer extends kelondroRowSet {int keylength = small.rowdef.width(0);assert (keylength == large.rowdef.width(0));indexContainer conj = new indexContainer(null, small.rowdef, 0); // start with empty search result- Iterator se = small.entries();+ Iterator<indexRWIRowEntry> se = small.entries();indexRWIEntry ie0, ie1;while (se.hasNext()) {ie0 = (indexRWIEntry) se.next();@@ -395,7 +395,7 @@ public class indexContainer extends kelondroRowSet {int keylength = pivot.rowdef.width(0);assert (keylength == excl.rowdef.width(0));boolean iterate_pivot = pivot.size() < excl.size();- Iterator se = (iterate_pivot) ? pivot.entries() : excl.entries();+ Iterator<indexRWIRowEntry> se = (iterate_pivot) ? pivot.entries() : excl.entries();indexRWIEntry ie0, ie1;while (se.hasNext()) {ie0 = (indexRWIEntry) se.next();diff --git a/source/de/anomic/index/indexRI.java b/source/de/anomic/index/indexRI.javaindex 652c1ec47..694ca4d19 100644--- a/source/de/anomic/index/indexRI.java+++ b/source/de/anomic/index/indexRI.java@@ -42,11 +42,11 @@ public interface indexRI {public long getUpdateTime(String wordHash);public int indexSize(String wordHash);public boolean hasContainer(String wordHash); // should only be used if in case that true is returned the getContainer is NOT called- public indexContainer getContainer(String wordHash, Set urlselection);+ public indexContainer getContainer(String wordHash, Set<String> urlselection); // if urlselection != null all url references which are not in urlselection are removed from the containerpublic indexContainer deleteContainer(String wordHash);public boolean removeEntry(String wordHash, String urlHash);- public int removeEntries(String wordHash, Set urlHashes);+ public int removeEntries(String wordHash, Set<String> urlHashes);public void addEntries(indexContainer newEntries, long creationTime, boolean dhtCase);public void close();diff --git a/source/de/anomic/kelondro/kelondroCollectionIndex.java b/source/de/anomic/kelondro/kelondroCollectionIndex.javaindex 733a47a77..90ac78871 100644--- a/source/de/anomic/kelondro/kelondroCollectionIndex.java+++ b/source/de/anomic/kelondro/kelondroCollectionIndex.java@@ -834,7 +834,7 @@ public class kelondroCollectionIndex {}- public synchronized int remove(byte[] key, Set<byte[]> removekeys) throws IOException, kelondroOutOfLimitsException {+ public synchronized int remove(byte[] key, Set<String> removekeys) throws IOException, kelondroOutOfLimitsException {if ((removekeys == null) || (removekeys.size() == 0)) return 0;@@ -857,9 +857,9 @@ public class kelondroCollectionIndex {kelondroRowSet oldcollection = getwithparams(indexrow, oldchunksize, oldchunkcount, oldPartitionNumber, oldrownumber, serialNumber, false);// remove the keys from the set- Iterator<byte[]> i = removekeys.iterator();+ Iterator<String> i = removekeys.iterator();while (i.hasNext()) {- if (oldcollection.remove(i.next(), false) != null) removed++;+ if (oldcollection.remove(i.next().getBytes(), false) != null) removed++;}oldcollection.sort();oldcollection.trim(false);diff --git a/source/de/anomic/kelondro/kelondroRowCollection.java b/source/de/anomic/kelondro/kelondroRowCollection.javaindex 1b456c48c..1a71bccdb 100644--- a/source/de/anomic/kelondro/kelondroRowCollection.java+++ b/source/de/anomic/kelondro/kelondroRowCollection.java@@ -441,7 +441,7 @@ public class kelondroRowCollection {}}- public synchronized void select(Set<kelondroRow.Entry> keys) {+ public synchronized void select(Set<String> keys) {// removes all entries but the ones given by urlselectionif ((keys == null) || (keys.size() == 0)) return;Iterator<kelondroRow.Entry> i = rows();diff --git a/source/de/anomic/kelondro/kelondroTree.java b/source/de/anomic/kelondro/kelondroTree.javaindex 496ef337e..0816a27ab 100644--- a/source/de/anomic/kelondro/kelondroTree.java+++ b/source/de/anomic/kelondro/kelondroTree.java@@ -199,7 +199,7 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex// temporary variablesprivate kelondroHandle thisHandle;- byte[] keybuffer;+ String keybuffer;protected Search() {}@@ -229,7 +229,7 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndexfound = false;int c;- TreeSet<byte[]> visitedNodeKeys = new TreeSet<byte[]>(loopDetectionOrder); // to detect loops+ TreeSet<String> visitedNodeKeys = new TreeSet<String>(loopDetectionOrder); // to detect loops// System.out.println("Starting Compare Loop in Database " + filename); // debugwhile (thisHandle != null) {try {@@ -242,7 +242,7 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex}if (thenode == null) throw new kelondroException(filename, "kelondroTree.Search.process: thenode==null");- keybuffer = thenode.getKey();+ keybuffer = new String(thenode.getKey());if (keybuffer == null) {// this is an error. distinguish two cases:// 1. thenode is a leaf node. Then this error can be fixed if we can consider this node as a good node to be replaced with a new value@@ -272,7 +272,7 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndexreturn;}// System.out.println("Comparing key = '" + new String(key) + "' with '" + otherkey + "':"); // debug- c = row().objectOrder.compare(key, keybuffer);+ c = row().objectOrder.compare(new String(key), keybuffer);// System.out.println(c); // debugif (c == 0) {found = true;@@ -986,12 +986,12 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex}}- public TreeMap<byte[], kelondroRow.Entry> rowMap(boolean up, byte[] firstKey, boolean including, int count) throws IOException {+ public TreeMap<String, kelondroRow.Entry> rowMap(boolean up, byte[] firstKey, boolean including, int count) throws IOException {// returns an ordered map of keys/row relations; key objects are of type String, value objects are of type byte[][]kelondroOrder setOrder = (kelondroOrder) row().objectOrder.clone();setOrder.direction(up);setOrder.rotate(firstKey);- TreeMap<byte[], kelondroRow.Entry> rows = new TreeMap<byte[], kelondroRow.Entry>(setOrder);+ TreeMap<String, kelondroRow.Entry> rows = new TreeMap<String, kelondroRow.Entry>(setOrder);CacheNode n;String key;synchronized (this) {@@ -1000,24 +1000,24 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndexn = i.next();if (n == null) return rows;key = new String(n.getKey());- if (rows.put(key.getBytes(), row().newEntry(n.getValueRow())) != null) return rows; // protection against loops+ if (rows.put(key, row().newEntry(n.getValueRow())) != null) return rows; // protection against loops}}return rows;}- public TreeSet<byte[]> keySet(boolean up, boolean rotating, byte[] firstKey, boolean including, int count) throws IOException {+ public TreeSet<String> keySet(boolean up, boolean rotating, byte[] firstKey, boolean including, int count) throws IOException {// returns an ordered set of keys; objects are of type StringkelondroOrder setOrder = (kelondroOrder) row().objectOrder.clone();setOrder.direction(up);setOrder.rotate(firstKey);- TreeSet<byte[]> set = new TreeSet<byte[]>(setOrder);+ TreeSet<String> set = new TreeSet<String>(setOrder);kelondroNode n;synchronized (this) {Iterator<CacheNode> i = (firstKey == null) ? new nodeIterator(up, rotating) : new nodeIterator(up, rotating, firstKey, including);while ((set.size() < count) && (i.hasNext())) {n = (kelondroNode) i.next();- if ((n != null) && (n.getKey() != null)) set.add(n.getKey());+ if ((n != null) && (n.getKey() != null)) set.add(new String(n.getKey()));}}return set;@@ -1037,8 +1037,8 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndexboolean inc;long count;byte[] lastKey;- TreeMap<byte[], kelondroRow.Entry> rowBuffer;- Iterator<Map.Entry<byte[], kelondroRow.Entry>> bufferIterator;+ TreeMap<String, kelondroRow.Entry> rowBuffer;+ Iterator<Map.Entry<String, kelondroRow.Entry>> bufferIterator;long guessedCountLimit;public rowIterator(boolean up, byte[] firstKey, long guessedCountLimit) throws IOException {@@ -1069,14 +1069,14 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndexpublic kelondroRow.Entry next() {if (!(bufferIterator.hasNext())) return null;- Map.Entry<byte[], kelondroRow.Entry> entry = bufferIterator.next();- lastKey = (byte[]) entry.getKey();+ Map.Entry<String, kelondroRow.Entry> entry = bufferIterator.next();+ lastKey = entry.getKey().getBytes();// check if this was the last entry in the rowBufferif (!(bufferIterator.hasNext())) {// assign next buffer chunktry {- lastKey[lastKey.length - 1]++;+ lastKey[lastKey.length - 1]++; // ***BUG??? FIXMErowBuffer = rowMap(inc, lastKey, false, chunkSize);bufferIterator = rowBuffer.entrySet().iterator();} catch (IOException e) {@@ -1111,8 +1111,8 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndexboolean inc;long count;byte[] lastKey;- TreeSet<byte[]> keyBuffer;- Iterator<byte[]> bufferIterator;+ TreeSet<String> keyBuffer;+ Iterator<String> bufferIterator;long guessedCountLimit;public keyIterator(boolean up, byte[] firstKey, long guessedCountLimit) throws IOException {@@ -1143,13 +1143,13 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndexpublic byte[] next() {if (!(bufferIterator.hasNext())) return null;- lastKey = bufferIterator.next();+ lastKey = bufferIterator.next().getBytes();// check if this was the last entry in the rowBufferif (!(bufferIterator.hasNext())) {// assign next buffer chunktry {- lastKey[lastKey.length - 1]++;+ lastKey[lastKey.length - 1]++; // ***BUG??? FIXMEkeyBuffer = keySet(inc, false, lastKey, false, chunkSize);bufferIterator = keyBuffer.iterator();} catch (IOException e) {diff --git a/source/de/anomic/plasma/plasmaSearchQuery.java b/source/de/anomic/plasma/plasmaSearchQuery.javaindex e506900e7..1e3809cd7 100644--- a/source/de/anomic/plasma/plasmaSearchQuery.java+++ b/source/de/anomic/plasma/plasmaSearchQuery.java@@ -51,6 +51,7 @@ import de.anomic.htmlFilter.htmlFilterAbstractScraper;import de.anomic.kelondro.kelondroBase64Order;import de.anomic.kelondro.kelondroBitfield;import de.anomic.kelondro.kelondroMSetTools;+import de.anomic.kelondro.kelondroNaturalOrder;import de.anomic.server.serverCharBuffer;import de.anomic.yacy.yacySeedDB;@@ -216,7 +217,7 @@ public plasmaSearchQuery(String queryString, TreeSet queryHashes, TreeSet excludpublic static TreeSet<String>[] cleanQuery(String querystring) {// returns two sets: a query set and a exclude set- if ((querystring == null) || (querystring.length() == 0)) return new TreeSet[]{new TreeSet<String>(), new TreeSet<String>()};+ if ((querystring == null) || (querystring.length() == 0)) return new TreeSet[]{new TreeSet<String>(kelondroNaturalOrder.naturalOrder), new TreeSet<String>(kelondroNaturalOrder.naturalOrder)};// convert Umlautequerystring = htmlFilterAbstractScraper.convertUmlaute(new serverCharBuffer(querystring.toCharArray())).toString();@@ -230,8 +231,8 @@ public plasmaSearchQuery(String queryString, TreeSet queryHashes, TreeSet exclud}// the string is clean now, but we must generate a set out of it- final TreeSet<String> query = new TreeSet<String>();- final TreeSet<String> exclude = new TreeSet<String>();+ final TreeSet<String> query = new TreeSet<String>(kelondroNaturalOrder.naturalOrder);+ final TreeSet<String> exclude = new TreeSet<String>(kelondroNaturalOrder.naturalOrder);final String[] a = querystring.split(" ");for (int i = 0; i < a.length; i++) {if (a[i].startsWith("-")) {diff --git a/source/de/anomic/plasma/plasmaWordIndex.java b/source/de/anomic/plasma/plasmaWordIndex.javaindex 4b3dff84f..4e27812d3 100644--- a/source/de/anomic/plasma/plasmaWordIndex.java+++ b/source/de/anomic/plasma/plasmaWordIndex.java@@ -458,7 +458,7 @@ public final class plasmaWordIndex implements indexRI {return removed;}- public int removeEntryMultiple(Set wordHashes, String urlHash) {+ public int removeEntryMultiple(Set<String> wordHashes, String urlHash) {// remove the same url hashes for multiple words// this is mainly used when correcting a index after a searchIterator i = wordHashes.iterator();@@ -469,7 +469,7 @@ public final class plasmaWordIndex implements indexRI {return count;}- public int removeEntries(String wordHash, Set urlHashes) {+ public int removeEntries(String wordHash, Set<String> urlHashes) {int removed = 0;synchronized (dhtInCache) {removed += dhtInCache.removeEntries(wordHash, urlHashes);@@ -483,7 +483,7 @@ public final class plasmaWordIndex implements indexRI {return removed;}- public String removeEntriesExpl(String wordHash, Set urlHashes) {+ public String removeEntriesExpl(String wordHash, Set<String> urlHashes) {String removed = "";synchronized (dhtInCache) {removed += dhtInCache.removeEntries(wordHash, urlHashes) + ", ";@@ -497,7 +497,7 @@ public final class plasmaWordIndex implements indexRI {return removed;}- public void removeEntriesMultiple(Set wordHashes, Set urlHashes) {+ public void removeEntriesMultiple(Set<String> wordHashes, Set<String> urlHashes) {// remove the same url hashes for multiple words// this is mainly used when correcting a index after a searchIterator i = wordHashes.iterator();@@ -506,7 +506,7 @@ public final class plasmaWordIndex implements indexRI {}}- public int removeWordReferences(Set words, String urlhash) {+ public int removeWordReferences(Set<String> words, String urlhash) {// sequentially delete all word references// returns number of deletionsIterator iter = words.iterator();