public Map<Long, Data> compareAndRemove(Collection<Data> dataList, boolean retain) {
        LinkedHashMap<Long, Data> map = new LinkedHashMap<Long, Data>();
        for (QueueItem item : getItemQueue()) {
            if (item.getData() == null && store.isEnabled()) {
                try {
                    load(item);
                } catch (Exception e) {
                    throw new HazelcastException(e);
                }
            }
            boolean contains = dataList.contains(item.getData());
            if ((retain && !contains) || (!retain && contains)) {
                map.put(item.getItemId(), item.getData());
            }
        }

        mapIterateAndRemove(map);

        return map;
    }
public Map < Long , Data > compareAndRemove ( Collection < Data > dataList , boolean retain ) { LinkedHashMap < Long , Data > map = new LinkedHashMap < Long , Data > ( ) ; for ( QueueItem item : getItemQueue ( ) ) { if ( item . getData ( ) == null && store . isEnabled ( ) ) { try { load ( item ) ; } catch ( Exception e ) { throw new HazelcastException ( e ) ; } } boolean contains = dataList . contains ( item . getData ( ) ) ; if ( ( retain && ! contains ) || ( ! retain && contains ) ) { map . put ( item . getItemId ( ) , item . getData ( ) ) ; } } mapIterateAndRemove ( map ) ; return map ; }
Compares if the queue contains the items in the dataList and removes them according to the retain parameter. If
the retain parameter is true, it will remove items which are not in the dataList (retaining the items which are in the
list). If the retain parameter is false, it will remove items which are in the dataList (retaining all other items which
are not in the list).
<p>
Note: this method will trigger store load.

@param dataList the list of items which are to be retained in the queue or which are to be removed from the queue
@param retain   does the method retain the items in the list (true) or remove them from the queue (false)
@return map of removed items by ID