# Invalidating iterator

This memory-efficient implementation, while necessary (the user won't have ridiculous amounts of RAM, most likely), together with the huge number of inputs, makes any operation on the cubes itself very expensive. A logic cube B is superfluous if there exists an (A, B), where for all inputs for which B is true, A is also true.

As an example, let's assume I have the logic cubes (of 2 inputs each) A=X1, B=11 and C=00.

Not much performance concern in building new lists even when fairly large. From what you wrote, it seems that the pairs are not directional, as in (A, B) is equal to (B, A). But then this clashes with the fact that you only remove the second element of the pair when the condition if satisfied.

I suspect there is no such implementation in Java because this type of list naturally pushes you in a tail recursive direction, which isn't properly optimized in Java.If you have to use Linked List I would do it like you did in your second example.It has n complexity, but at least it's not exponential.A and C, however, are not superfluous and need to be kept.An important characteristic of such a superfluous logic cube, is that if (B, C) fulfills the condition, and (A, B) as well, then (A, C) also fulfills the condition for sure (both B and C are superfluous).