int source = getConnectionsStoreIndexStart() + rand.nextInt(this.getConnectionsStoreCapacity());
int target = getElementStoreIndexStart() + rand.nextInt(getElementStoreCapacity());
String key = source + "=>" + target;
if(!map.containsKey(key)) {
Connection conn = new SimpleConnection(source, target, true);
conn.setStrength(rand.nextInt(1000000));
map.put(key, conn);
list.add(conn);
}
}
// Index active connections
for(Connection conn : list) {
conn.setTimestamp(scn++);
typeahead.index(conn);
}
for(Connection conn : list) {
assertEquals(conn.getStrength(), store.getWeight(conn.source(), conn.target()));
int[][] dat = store.getWeightData(conn.source());
assertEquals(2, dat.length);
assertTrue(dat[ArrayStoreWeights.ELEMID_SUBARRAY_INDEX].length > 0);
assertTrue(dat[ArrayStoreWeights.ELEMID_SUBARRAY_INDEX].length == dat[ArrayStoreWeights.WEIGHT_SUBARRAY_INDEX].length);
}
// Index inactive connections
for(Connection conn : list) {
conn.setActive(false);
conn.setTimestamp(scn++);
typeahead.index(conn);
}
for(Connection conn : list) {
assertEquals(0, store.getWeight(conn.source(), conn.target()));
int[][] dat = store.getWeightData(conn.source());
assertEquals(2, dat.length);
assertEquals(0, dat[ArrayStoreWeights.ELEMID_SUBARRAY_INDEX].length);
assertTrue(dat[ArrayStoreWeights.ELEMID_SUBARRAY_INDEX].length == dat[ArrayStoreWeights.WEIGHT_SUBARRAY_INDEX].length);
}
}