public AttributeSet[] getTreeChildren() { int attrAmount = attributes.size(); if (attrAmount <= 1) { return new AttributeSet[0]; } final AttributeSet[] children = new AttributeSet[attrAmount]; Iterator<Attribute> it = attributes.iterator(); Attribute attr = it.next(); for (int i = 0; ; ++i) { SortedSet<Attribute> childAttr = attributes.headSet(attr); if (it.hasNext()) { attr = it.next(); childAttr = new TreeSet<>(childAttr); childAttr.addAll(attributes.tailSet(attr)); children[i] = AttributeSet.getSet(childAttr); } else { children[i] = AttributeSet.getSet(childAttr); return children; } } }
public AttributeSet merge(final AttributeSet other) { SortedSet<Attribute> newSet = new TreeSet<>(attributes); newSet.addAll(other.attributes); return AttributeSet.getSet(newSet); }
public static AttributeSet getSet(final Attribute attribute) { SortedSet<Attribute> set = new TreeSet<>(); set.add(attribute); return AttributeSet.getSet(set); }