component/src/main/java/org/wso2/extension/siddhi/execution/extrema/util/AbstractTopKBottomKFinder.java
public void offer(T item, int incrementCount) {
        if (incrementCount == 0) {
            return;
        }
        ListNode<Counter<T>> counterNode = counterMap.get(item);
        if (counterNode == null) {
            // New counter needs to be added
            if (counterMap.size() >= capacity) {
                // Least important counter needs to be removed (Importance depends on whether it is topK or bottomK)
                // Then new bucket needs to be added
                DoublyLinkedList<Counter<T>> counterList =
                        getBucketWithCounterToReplace().getCounterList();

                // Removing the least important counter from the bucket and the counter map
                counterList.remove(counterList.head());
                counterMap.remove(item);
            }
            counterNode = bucketList.addBeforeFirst(new Bucket(0))
                    .getValue().getCounterList()
                    .addAfterLast(new Counter<T>(bucketList.head(), item));
            counterMap.put(item, counterNode);
        }
        incrementCounter(counterNode, incrementCount);
    }
/**
     * Increases the frequency of the item by the specified amount
     *
     * @param item Item to increase the frequency of
     * @param incrementCount Amount to be incremented
     */
Increases the frequency of the item by the specified amount
@param item Item to increase the frequency of
@param incrementCount Amount to be incremented
Increases the frequency of the item by the specified amount @param item Item to increase the frequency of @param incrementCount Amount to be incremented
public void offer(T item, int incrementCount) {
        if (incrementCount == 0) {
            return;
        }
        ListNode<Counter<T>> counterNode = counterMap.get(item);
        if (counterNode == null) {
            if (counterMap.size() >= capacity) {
                DoublyLinkedList<Counter<T>> counterList =
                        getBucketWithCounterToReplace().getCounterList();
                counterList.remove(counterList.head());
                counterMap.remove(item);
            }
            counterNode = bucketList.addBeforeFirst(new Bucket(0))
                    .getValue().getCounterList()
                    .addAfterLast(new Counter<T>(bucketList.head(), item));
            counterMap.put(item, counterNode);
        }
        incrementCounter(counterNode, incrementCount);
    }
public void offer ( T item , int incrementCount ) { if ( incrementCount == 0 ) { return ; } ListNode < Counter < T > > counterNode = counterMap . get ( item ) ; if ( counterNode == null ) { if ( counterMap . size ( ) >= capacity ) { DoublyLinkedList < Counter < T > > counterList = getBucketWithCounterToReplace ( ) . getCounterList ( ) ; counterList . remove ( counterList . head ( ) ) ; counterMap . remove ( item ) ; } counterNode = bucketList . addBeforeFirst ( new Bucket ( 0 ) ) . getValue ( ) . getCounterList ( ) . addAfterLast ( new Counter < T > ( bucketList . head ( ) , item ) ) ; counterMap . put ( item , counterNode ) ; } incrementCounter ( counterNode , incrementCount ) ; }
Increases the frequency of the item by the specified amount
 @param item Item to increase the frequency of
 @param incrementCount Amount to be incremented
Increases the frequency of the item by the specified amount @param item Item to increase the frequency of @param incrementCount Amount to be incremented
// New counter needs to be added // Least important counter needs to be removed (Importance depends on whether it is topK or bottomK) // Then new bucket needs to be added // Removing the least important counter from the bucket and the counter map