class TEWMA {

    public double add(Object item, double quantity, long timestamp) {
        // compute the hash functions
        int[] idx = indexes(item);
        
        double minCounter = getMinCounter(idx, timestamp);
        
        // compute the new value including the insertion and update 
	// the filter by waterfilling the new counter array bins
        double newCounter = minCounter + quantity * logBeta;
        
        if (newCounter > 1.0e99)
            throw new AssertionError("newCounter shouldn't be greater than 1.0e99.");
        
        for (int i=0; i<nhash; i++)
            if (counters[idx[i]] < newCounter)
                counters[idx[i]] = newCounter;
        
        return newCounter;
    }

    public  TEWMA(int nhash, int shash, double beta, double w);

}