### Question:
PartiallyOrderedSet extends AbstractSet<E> { @Override public boolean add( E e ) { assert e != null; assert !DEBUG || isValid( true ); Node<E> node = map.get( e ); if ( node != null ) { return false; } Set<Node<E>> parents = findParents( e ); Set<Node<E>> children = findChildren( e ); node = new Node<>( e ); for ( Node<E> parent : parents ) { node.parentList.add( parent ); int n = 0; for ( int i = 0; i < parent.childList.size(); i++ ) { Node<E> child = parent.childList.get( i ); if ( child.e == null || ordering.lessThan( child.e, e ) ) { if ( parent.childList.contains( node ) ) { parent.childList.remove( i ); --i; } else { parent.childList.set( i, node ); } replace( child.parentList, parent, node ); if ( !node.childList.contains( child ) ) { node.childList.add( child ); } ++n; } } if ( n == 0 ) { parent.childList.add( node ); } } final Set<Node<E>> childSet = new HashSet<>( node.childList ); for ( Node<E> child : children ) { if ( !isDescendantOfAny( child, childSet ) ) { node.childList.add( child ); if ( !child.parentList.contains( node ) ) { child.parentList.add( node ); } } } map.put( node.e, node ); assert !DEBUG || isValid( true ); return true; } PartiallyOrderedSet( Ordering<E> ordering );  PartiallyOrderedSet( Ordering<E> ordering, Function<E, Iterable<E>> childFunction, Function<E, Iterable<E>> parentFunction );  PartiallyOrderedSet( Ordering<E> ordering, Collection<E> collection ); private  PartiallyOrderedSet( Ordering<E> ordering, Map<E, Node<E>> map, Function<E, Iterable<E>> childFunction, Function<E, Iterable<E>> parentFunction ); @SuppressWarnings("NullableProblems") @Override Iterator<E> iterator(); @Override int size(); @Override boolean contains( Object o ); @Override boolean remove( Object o ); @Override boolean add( E e ); boolean isValid( boolean fail ); void out( StringBuilder buf ); List<E> getChildren( E e ); List<E> getChildren( E e, boolean hypothetical ); List<E> getParents( E e ); List<E> getParents( E e, boolean hypothetical ); List<E> getNonChildren(); List<E> getNonParents(); @Override void clear(); List<E> getDescendants( E e ); static List<E> strip( List<Node<E>> list ); List<E> getAncestors( E e ); static final Ordering<ImmutableBitSet> BIT_SET_INCLUSION_ORDERING; }### Answer:
@Test public void testPosetBitsLarge2() { Assume.assumeTrue( "too slow to run every day", PolyphenyDbAssert.ENABLE_SLOW ); final int n = 30000; final PartiallyOrderedSet<Integer> poset = new PartiallyOrderedSet<>( PartiallyOrderedSetTest::isBitSuperset, (Function<Integer, Iterable<Integer>>) i -> { int r = Objects.requireNonNull( i ); final List<Integer> list = new ArrayList<>(); for ( int z = 1; r != 0; z <<= 1 ) { if ( (i & z) != 0 ) { list.add( i ^ z ); r ^= z; } } return list; }, i -> { Objects.requireNonNull( i ); final List<Integer> list = new ArrayList<>(); for ( int z = 1; z <= n; z <<= 1 ) { if ( (i & z) == 0 ) { list.add( i | z ); } } return list; } ); checkPosetBitsLarge( poset, n, 2921, 11961 ); }