<commit_before>/*
 * #%L
 * elk-reasoner
 * 
 * $Id$
 * $HeadURL$
 * %%
 * Copyright (C) 2011 Oxford University Computing Laboratory
 * %%
 * 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.
 * #L%
 */
package org.semanticweb.elk.reasoner.saturation;

import java.util.Queue;
import java.util.Set;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicBoolean;

import org.semanticweb.elk.reasoner.indexing.IndexedClassExpression;
import org.semanticweb.elk.reasoner.indexing.IndexedObjectProperty;
import org.semanticweb.elk.util.ArrayHashSet;
import org.semanticweb.elk.util.HashSetMultimap;
import org.semanticweb.elk.util.Multimap;
import org.semanticweb.elk.util.Pair;

/**
 * @author <NAME>
 * 
 */
public class Context {
	final IndexedClassExpression root;
	final Queue<IndexedClassExpression> classQueue;
	final Queue<Pair<IndexedObjectProperty, Context>> linkQueue;
	final Queue<Pair<IndexedObjectProperty, IndexedClassExpression>> propagationQueue;
	final Set<IndexedClassExpression> derived;
	final Multimap<IndexedObjectProperty, Context> linksByObjectProperty;
	final Multimap<IndexedObjectProperty, IndexedClassExpression> propagationsByObjectProperty;
	// Context is active iff one of its queues is not empty or it is being
	// processed
	private AtomicBoolean isActive;

	public Context(IndexedClassExpression root) {
		this.root = root;
		this.classQueue = new ConcurrentLinkedQueue<IndexedClassExpression>();
		this.linkQueue = 
			new ConcurrentLinkedQueue<Pair<IndexedObjectProperty, Context>>();
		this.propagationQueue = 
			new ConcurrentLinkedQueue<Pair<IndexedObjectProperty, IndexedClassExpression>>();
		this.derived = new ArrayHashSet<IndexedClassExpression>(13);
		this.linksByObjectProperty = 
			new HashSetMultimap<IndexedObjectProperty, Context>(1);
		this.propagationsByObjectProperty = 
			new HashSetMultimap<IndexedObjectProperty, IndexedClassExpression> (1);
		this.isActive = new AtomicBoolean(false);
	}

	public IndexedClassExpression getRoot() {
		return root;<commit_msg>+some documentation<commit_after>/*
 * #%L
 * elk-reasoner
 * 
 * $Id$
 * $HeadURL$
 * %%
 * Copyright (C) 2011 Oxford University Computing Laboratory
 * %%
 * 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.
 * #L%
 */
package org.semanticweb.elk.reasoner.saturation;

import java.util.Queue;
import java.util.Set;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicBoolean;

import org.semanticweb.elk.reasoner.indexing.IndexedClassExpression;
import org.semanticweb.elk.reasoner.indexing.IndexedObjectProperty;
import org.semanticweb.elk.util.ArrayHashSet;
import org.semanticweb.elk.util.HashSetMultimap;
import org.semanticweb.elk.util.Multimap;
import org.semanticweb.elk.util.Pair;

/**
 * Objects of this class are used to manage subsumption relations between class
 * expressions that are derived during saturation. Besides storing consequences,
 * they also provide facilities for managing the processing of new derivations,
 * ensuring that only new derivations are used when searching for applicable
 * derivation rules.
 * 
 * @author <NAME>
 */
public class Context {
	final IndexedClassExpression root;
	final Queue<IndexedClassExpression> classQueue;
	final Queue<Pair<IndexedObjectProperty, Context>> linkQueue;
	final Queue<Pair<IndexedObjectProperty, IndexedClassExpression>> propagationQueue;
	final Set<IndexedClassExpression> derived;
	final Multimap<IndexedObjectProperty, Context> linksByObjectProperty;
	final Multimap<IndexedObjectProperty, IndexedClassExpression> propagationsByObjectProperty;
	/**
	 * A context is active iff one of its queues is not empty or it is being
	 * processed.
	 */
	private AtomicBoolean isActive;

	public Context(IndexedClassExpression root) {
		this.root = root;
		this.classQueue = new ConcurrentLinkedQueue<IndexedClassExpression>();
		this.linkQueue = new ConcurrentLinkedQueue<Pair<IndexedObjectProperty, Context>>();
		this.propagationQueue = new ConcurrentLinkedQueue<Pair<IndexedObjectProperty, IndexedClassExpression>>();
		this.derived = new ArrayHashSet<IndexedClassExpression>(13);
		this.linksByObjectProperty = new HashSetMultimap<IndexedObjectProperty, Context>(
				1);
		this.propagationsByObjectProperty = new HashSetMultimap<IndexedObjectProperty, IndexedClassExpression>(
				1);
		this.isActive = new AtomicBoolean(false);
	}

	public IndexedClassExpression getRoot() {
		return root;
{'fraction_non_alphanumeric': 0.08560453630876166, 'fraction_numerical': 0.004389976220962136, 'mean_word_length': 5.471005917159763, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1796265', 'n_tokens_mistral': 1609, 'n_tokens_neox': 1524, 'n_words': 443}