public int size() { int size = cleared ? 0 : snapshot.size(); for (Map.Entry<RowKey, AssociationOperation> op : currentState.entrySet()) { switch (op.getValue().getType()) { case PUT: case PUT_NULL: if (cleared || !snapshot.containsKey(op.getKey())) { size++; } break; case REMOVE: if (!cleared && snapshot.containsKey(op.getKey())) { size--; } break; } } return size; }