org.drools.core.util.CodedHierarchy Maven / Gradle / Ivy
/*
* Copyright 2013 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.drools.core.util;
import java.util.BitSet;
import java.util.Collection;
import java.util.List;
import java.util.Map;
public interface CodedHierarchy {
public int size();
public void addMember( T val, BitSet key );
public void removeMember( T val );
public void removeMember( BitSet key );
public BitSet getCode( T val );
public BitSet metMembersCode( Collection vals );
public BitSet jointMembersCode( Collection vals );
public BitSet meetCode( Collection codes );
public BitSet joinCode( Collection codes );
public List getSortedMembers();
public Map getSortedMap();
public T getMember( BitSet key );
public boolean hasKey( BitSet key );
// These methods assume that a node is known, by value or key, and will navigate the precomputed structure
public Collection children( T y );
public Collection descendants( T y );
public Collection children( BitSet key );
public Collection descendants( BitSet key );
// These methods will work for any key code
/**
* Return the "ceiling" of the key's descendants, up to and including the element whose code is key
* @param key a key, possibly the join of a number of member keys
* @return
*/
public Collection lowerBorder( BitSet key );
/**
* * Return the "ceiling" of the key's descendants, excluding the element whose code is key, if any
* @param key a key, possibly the join of a number of member keys
* @return
*/
public Collection immediateChildren( BitSet key );
/**
* Returns all elements whose code is a descendant of key
* @param key
* @return
*/
public Collection lowerDescendants( BitSet key );
// These methods assume that a node is known, by value or key, and will navigate the precomputed structure
public Collection parents( T x );
public Collection parents( BitSet x );
public Collection ancestors( T x );
public Collection ancestors( BitSet key );
// These methods work with a generic key, which need not correspond to a particular element
/**
* Return the "floor" of the key's ancestors, down to and including the element whose code is key, if any
* @param key a key, possibly the meet of a number of member keys
* @return
*/
public Collection upperBorder( BitSet key );
/**
*
* Return the "floor" of the key's ancetsors, down to and excluding the element whose code is key
* @param key a key, possibly the meet of a number of member keys
* @return
*/
public Collection immediateParents( BitSet key );
/**
* Returns all elements whose code is an ancestor of key
* @param key
* @return
*/
public Collection upperAncestors( BitSet key );
}