Modify the given collection of {@link EquivalentFragmentSet} to introduce certain optimisations, such as the
{@link AttributeIndexFragmentSet}.
<p>
This involves substituting various {@link EquivalentFragmentSet} with other {@link EquivalentFragmentSet}.
761626
public static void optimiseFragmentSets(
            Collection<EquivalentFragmentSet> fragmentSets, TransactionOLTP tx) {

        // Repeatedly apply optimisations until they don't alter the query
        boolean changed = true;

        while (changed) {
            changed = false;
            for (FragmentSetOptimisation optimisation : OPTIMISATIONS) {
                changed |= optimisation.apply(fragmentSets, tx);
            }
        }
    }
1081218
public void setSearchableAttributes(java.util.Collection<String> searchableAttributes) {
        if (searchableAttributes == null) {
            this.searchableAttributes = null;
            return;
        }

        this.searchableAttributes = new java.util.ArrayList<String>(searchableAttributes);
    }
526771
public void setAttributeSet(ElemAttributeSet attrSet)
  {

    if (null == m_attributeSets)
    {
      m_attributeSets = new Vector();
    }

    m_attributeSets.addElement(attrSet);
  }
224533
public void addVerticesToSet(Set<VertexType> set) {
        // Add the vertex for this object
        set.add(this.m_vertex);

        // Add vertices for all children
        Iterator<SearchTree<VertexType>> i = childIterator();
        while (i.hasNext()) {
            SearchTree<VertexType> child = i.next();
            child.addVerticesToSet(set);
        }
    }
94620
@Override
    public <O extends Comparable> Set<O> transform(Set<O> set) {
        return checkNotNull(set);
    }
1135500
public void setCustomAttributes(java.util.Collection<SchemaAttributeType> customAttributes) {
        if (customAttributes == null) {
            this.customAttributes = null;
            return;
        }

        this.customAttributes = new java.util.ArrayList<SchemaAttributeType>(customAttributes);
    }
117302
@Override
    public void setMoleculeSet(IAtomContainerSet setOfMolecules) {
        if (this.setOfMolecules != null) this.setOfMolecules.removeListener(this);
        this.setOfMolecules = setOfMolecules;
        if (this.setOfMolecules != null) this.setOfMolecules.addListener(this);
        notifyChanged();
    }
299833
@Override
    public List<Object> setAttributeValues(final String name, final List<Object> values) {
        List<Object> replacedValues = null;

        for (final IAdditionalDescriptors additionalDescriptors : delegateDescriptors) {
            final List<Object> oldValues = additionalDescriptors.setAttributeValues(name, values);
            if (oldValues != null) {
                if (replacedValues == null) {
                    replacedValues = new ArrayList<>(oldValues);
                } else {
                    replacedValues.addAll(oldValues);
                }
            }
        }

        return replacedValues;
    }
272199
@Override
    public Set entrySet() {
        if (entrySet != null) {
            return entrySet;
        }
        entrySet = new AbstractSet() {
            @Override
            public int size() {
                return ReferenceMap.this.size();
            }


            @Override
            public void clear() {
                ReferenceMap.this.clear();
            }


            @Override
            public boolean contains(final Object o) {
                if (o == null) {
                    return false;
                }
                if (!(o instanceof Map.Entry)) {
                    return false;
                }
                final Map.Entry e = (Map.Entry) o;
                final Entry e2 = getEntry(e.getKey());
                return (e2 != null) && e.equals(e2);
            }


            @Override
            public boolean remove(final Object o) {
                final boolean r = contains(o);
                if (r) {
                    final Map.Entry e = (Map.Entry) o;
                    ReferenceMap.this.remove(e.getKey());
                }
                return r;
            }


            @Override
            public Iterator iterator() {
                return new EntryIterator();
            }

            @Override
            public Object[] toArray() {
                return toArray(new Object[0]);
            }


            @Override
            @SuppressWarnings("unchecked")
            public Object[] toArray(final Object[] arr) {
                final List list = new ArrayList();
                final Iterator iterator = iterator();
                while (iterator.hasNext()) {
                    final Entry e = (Entry) iterator.next();
                    list.add(new DefaultMapEntry(e.getKey(), e.getValue()));
                }
                return list.toArray(arr);
            }
        };
        return entrySet;
    }
1000802
private void doSimpleMatching() {
        for (int i = 0; i < equalElements.size(); i++) {
            if (!alreadyMatched.get(i)) {
                List<Integer> equalTo = equalElements.get(i);
                if (equalTo.size() > 0) {
                    List<Integer> equivalentElements = getEquivalentElements(equalTo);

                    // We have the same set matching as is equivalent, we can remove them all
                    if (equalTo.size() == equivalentElements.size()) {
                        for (int j = 0; j < equivalentElements.size(); j++) {
                            recordMatch(equivalentElements.get(j), equalTo.get(j));
                        }
                    } else if (equivalentElements.size() > 1 && equalTo.size() > 1) {
                        List<Integer> equalToUsedOnlyInEquivalentElements = getEqualToUsedOnlyInEquivalentElements(equalTo, equivalentElements);
                        for (int j = 0; j < min(equivalentElements.size(), equalToUsedOnlyInEquivalentElements.size()); j++) {
                            recordMatch(equivalentElements.get(j), equalTo.get(j));
                        }
                    }
                }
            }
        }
    }
10272
private static ImmutableSet<RelationID> attributeOccurrencesUnion(QuotedID id,
                                                                      RAExpressionAttributes re1,
                                                                      RAExpressionAttributes re2) {

        ImmutableSet<RelationID> s1 = re1.attributeOccurrences.get(id);
        ImmutableSet<RelationID> s2 = re2.attributeOccurrences.get(id);

        if (s1 == null)
            return s2;

        if (s2 == null)
            return s1;

        return ImmutableSet.<RelationID>builder().addAll(s1).addAll(s2).build();
    }
306464
@Override
    public void setAttributes(Map<String, List<String>> attributes) {
        // Tries to modify as many of the existing attributes in place to reduce DB churn in
        // hibernate

        // Make a local copy so we don't edit the original reference
        attributes = new LinkedHashMap<String, List<String>>(attributes);

        for (final Iterator<LocalAccountPersonAttributeImpl> attributesItr =
                        this.attributes.iterator();
                attributesItr.hasNext(); ) {
            final LocalAccountPersonAttributeImpl attribute = attributesItr.next();

            // Remove the new values for the attribute from the input map
            final String name = attribute.getName();
            final List<String> newValues = attributes.remove(name);

            // If no new values remove the attribute
            if (newValues == null) {
                attributesItr.remove();
            }
            // Otherwise update the existing values
            else {
                attribute.setValues(new ArrayList<String>(newValues));
            }
        }

        // Add any remaining new attributes to the list
        for (final Map.Entry<String, List<String>> attribute : attributes.entrySet()) {
            final String name = attribute.getKey();
            final List<String> values = attribute.getValue();
            this.attributes.add(new LocalAccountPersonAttributeImpl(name, values));
        }
    }
152789
public void setRangesOnIndexedValues(java.util.Collection<ObjectAttributeRange> rangesOnIndexedValues) {
        if (rangesOnIndexedValues == null) {
            this.rangesOnIndexedValues = null;
            return;
        }

        this.rangesOnIndexedValues = new java.util.ArrayList<ObjectAttributeRange>(rangesOnIndexedValues);
    }
149582
private void discoverAttributeMethods(Map<String, JmxAttributeMethodInfo> attributeMethodInfoMap,
			Set<String> attributeNameSet, List<MBeanAttributeInfo> attributes, boolean ignoreErrors) {
		for (Class<?> clazz = target.getClass(); clazz != Object.class; clazz = clazz.getSuperclass()) {
			discoverAttributeMethods(attributeMethodInfoMap, attributeNameSet, attributes, ignoreErrors, clazz);
		}
		/*
		 * we have to go back and post process the attribute-method-map because the getter and setter methods change the
		 * method-info multiple times.
		 */
		for (AttributeMethodInfo methodInfo : attributeMethodMap.values()) {
			attributes.add(new MBeanAttributeInfo(methodInfo.varName, methodInfo.type.getName(),
					methodInfo.description, (methodInfo.getterMethod != null), (methodInfo.setterMethod != null),
					methodInfo.isIs()));
			attributeNameSet.add(methodInfo.varName);
		}
	}
333300
public void replaceAttribute(Attribute original, Attribute newAttribute) {
		for (ListIterator<Attribute> it = attributes.listIterator(); it.hasNext(); )
			if (it.next().equals(original)) {
				it.set(newAttribute);
				break;
			}
	}
437533
public void setSchemaSet(ConnectionSchemaSet schemaSet)
   {
     if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "setSchemaSet", schemaSet);
     getConversation().setSchemaSet(schemaSet);
     if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "setSchemaSet");
   }
342393
public static <T> TreeSet<T> newSortedSet(@Nullable Comparator<? super T> comparator) {
		return Sets.newTreeSet(comparator);
	}