code: private void InvalidateCaches(int diff) {
      if (diff == 0xffffffff) {
        // Everything must go.
        cached_bags_.clear();
        return;
      }
  
      // Be more conservative with what gets purged. Only if the bag has other possible
      // variations with respect to what changed (diff) should we remove it.
      // for (auto iter = cached_bags_.cbegin(); iter != cached_bags_.cend();) {
      for (Integer key : new ArrayList<>(cached_bags_.keySet())) {
        // if (diff & iter.second.type_spec_flags) {
        if (isTruthy(diff & cached_bags_.get(key).type_spec_flags)) {
          // iter = cached_bags_.erase(iter);
          cached_bags_.remove(key);
        }
      }
    }
docs: void InvalidateCaches(int diff);