<commit_before>/*******************************************************************************
 *
 *    Copyright (C) 2015-2017 the BBoxDB project
 *  
 *    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.bboxdb.storage.entity;

public class DoubleInterval implements Comparable<DoubleInterval> {
	
	/**
	 * The begin of the interval
	 */
	protected final double begin;
	
	/**
	 * The end of the interval
	 */
	protected final double end;
	
	/**
	 * Begin point included
	 */
	protected final boolean beginIncluded;
	
	/**
	 * End point included
	 */
	protected final boolean endIncluded;
	
	public DoubleInterval(final double begin, final double end) {
		this(begin, end, true, true);
	}

	public DoubleInterval(final double begin, final double end, final boolean beginIncluded, final boolean endIncluded) {
		super();
		
		if(begin > end) {
			throw new IllegalArgumentException("Failed to construct an interval with: begin " 
					+ begin + " > end " + end);
		}
		
		if(begin == end) {
			if(beginIncluded == false || endIncluded == false) {
				throw new IllegalArgumentException("Unable to construct open interval with: begin = end");
			}
		}
		
		this.begin = begin;
		this.end = end;
		this.beginIncluded = beginIncluded;
		this.endIncluded = endIncluded;
	}

	/**
	 * Is the begin included?
	 * @return
	 */
	public boolean isBeginIncluded() {
		return beginIncluded;
	}

	/**
	 * Is the end point included
	 * @return
	 */
	public boolean isEndIncluded() {
		return endIncluded;
	}

	/**
	 * Get the begin of the interval
	 * @return
	 */
	public double getBegin() {
		return begin;
	}

	/**
	 * Get the end of the interval
	 * @return
	 */
	public double getEnd() {
		return end;
	}
	
	/**
	 * Get the middle point of the interval
	 * @return
	 */
	public double getMidpoint() {
		return ((end - begin) / 2.0) + begin;
	}
	
	/**
	 * Is the number covered by the interval?
	 * @param number
	 * @return
	 */
	public boolean isNumberIncluded(final double number) {
		return overlapsWith(number, true);
	}<commit_msg>Added getLength method<commit_after>/*******************************************************************************
 *
 *    Copyright (C) 2015-2017 the BBoxDB project
 *  
 *    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.bboxdb.storage.entity;

public class DoubleInterval implements Comparable<DoubleInterval> {
	
	/**
	 * The begin of the interval
	 */
	protected final double begin;
	
	/**
	 * The end of the interval
	 */
	protected final double end;
	
	/**
	 * Begin point included
	 */
	protected final boolean beginIncluded;
	
	/**
	 * End point included
	 */
	protected final boolean endIncluded;
	
	public DoubleInterval(final double begin, final double end) {
		this(begin, end, true, true);
	}

	public DoubleInterval(final double begin, final double end, final boolean beginIncluded, final boolean endIncluded) {
		super();
		
		if(begin > end) {
			throw new IllegalArgumentException("Failed to construct an interval with: begin " 
					+ begin + " > end " + end);
		}
		
		if(begin == end) {
			if(beginIncluded == false || endIncluded == false) {
				throw new IllegalArgumentException("Unable to construct open interval with: begin = end");
			}
		}
		
		this.begin = begin;
		this.end = end;
		this.beginIncluded = beginIncluded;
		this.endIncluded = endIncluded;
	}

	/**
	 * Is the begin included?
	 * @return
	 */
	public boolean isBeginIncluded() {
		return beginIncluded;
	}

	/**
	 * Is the end point included
	 * @return
	 */
	public boolean isEndIncluded() {
		return endIncluded;
	}

	/**
	 * Get the begin of the interval
	 * @return
	 */
	public double getBegin() {
		return begin;
	}

	/**
	 * Get the end of the interval
	 * @return
	 */
	public double getEnd() {
		return end;
	}
	
	/**
	 * Get the middle point of the interval
	 * @return
	 */
	public double getMidpoint() {
		return (getLength() / 2.0) + begin;
	}

	/**
	 * Get the length of the interval
	 * @return
	 */
	public double getLength() {
		return end - begin;
	}
	
	/**
	 * Is the number covered by the interval?
	 * @param number
	 * @return
	 */
	public boolean isNumberIncluded(final double number) {
		return overlapsWith(number, true);
	}
{'fraction_non_alphanumeric': 0.1516822945394374, 'fraction_numerical': 0.005148005148005148, 'mean_word_length': 3.2072699149265276, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '3313292', 'n_tokens_mistral': 1667, 'n_tokens_neox': 1460, 'n_words': 546}