TEWMA { protected int[] indexes(Object o) { int[] indexes = new int[nhash]; byte[] msgDigest = toSHA1(o); int numBytes = shash/8; int k = 0; for (int i=0; i<nhash; i++) { byte[] bytes = new byte[numBytes]; for (int j=numBytes-1; j>=0; j--, k++) { if (k >= msgDigest.length) { msgDigest = toSHA1(msgDigest); k = 0; } bytes[j] = msgDigest[k]; } String hex = bytesToHex(bytes); indexes[i] = Integer.parseInt(hex, 16); } return indexes; } TEWMA(int nhash, int shash, double beta, double w); double add(Object item, double quantity, long timestamp); double check(Object item, long timestamp);  }
@Test public void testIndexes() throws NoSuchAlgorithmException { TEWMA tewma = new TEWMA(16, 24, 1, 1); int[] indexes = tewma.indexes(message); System.out.println("Indexes:"); for (int i=0; i<indexes.length; i++) { assertEquals(correctIdx[i], indexes[i]); System.out.println(indexes[i]); } }