Skip to content

Commit

Permalink
Some initial hacking
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Schlansker committed Sep 23, 2009
1 parent 9c2a818 commit bcb3205
Show file tree
Hide file tree
Showing 10 changed files with 368 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#Tue Sep 22 16:28:01 PDT 2009
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.5
9 changes: 9 additions & 0 deletions .settings/org.maven.ide.eclipse.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#Tue Sep 22 16:27:12 PDT 2009
activeProfiles=
eclipse.preferences.version=1
fullBuildGoals=process-test-resources
includeModules=false
resolveWorkspaceProjects=true
resourceFilterGoals=process-resources resources\:testResources
skipCompilerPlugin=true
version=1
61 changes: 61 additions & 0 deletions src/main/java/org/sugis/intervalmap/Interval.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package org.sugis.intervalmap;

import javax.annotation.Nonnull;
import javax.annotation.concurrent.Immutable;

/**
* An Interval is an immutable range over any Comparable
* types - they do not necessarily need to be numbers.
* @author Steven Schlansker
* @param <K> the type of the bounds on the interval
*/
@Immutable
public class Interval<K extends Comparable<K>> {

/* begin <= end */
private final K lower, upper;

/**
* Construct a new Interval
* @param lower_in the beginning of the interval
* @param upper_in the end of the interval
*/
public Interval(@Nonnull K lower_in, @Nonnull K upper_in) {
if (lower_in.compareTo(upper_in) > 0) {
lower = upper_in;
upper = lower_in;
} else {
lower = lower_in;
upper = upper_in;
}
}

/**
* @return the lower bound given at construction
*/
public K getLowerBound() { return lower; }

/**
* @return the upper bound given at construction
*/
public K getUpperBound() { return upper; }

@Override
public String toString() {
return "Interval[" + lower + "," + upper + "]";
}

@Override
public boolean equals(Object obj) {
if (! (obj instanceof Interval<?>) )
return false;
Interval<?> other = (Interval<?>) obj;
return other.upper.equals(upper) && other.lower.equals(lower);
}

@Override
public int hashCode() {
return lower.hashCode() ^ upper.hashCode();
}

}
84 changes: 84 additions & 0 deletions src/main/java/org/sugis/intervalmap/IntervalMap.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package org.sugis.intervalmap;

import java.util.Collection;
import java.util.Map;
import java.util.Set;

import javax.annotation.concurrent.NotThreadSafe;

/**
* An IntervalMap represents a map of Interval objects to values,
* with the additional ability to query with a single parameter
* and find the values of all intervals that contain it.
* @author Steven Schlansker
* @param <K> the type of the intervals' bounds
* @param <V> the type of the values stored in the Map
*/
@NotThreadSafe
public class IntervalMap<K extends Comparable<K>, V> implements Map<Interval<K>, V> {

public Set<Entry<Interval<K>, V>> getContaining(K point) {
return null;
}

public void clear() {
// TODO Auto-generated method stub

}

public boolean containsKey(Object key) {
// TODO Auto-generated method stub
return false;
}

public boolean containsValue(Object value) {
// TODO Auto-generated method stub
return false;
}

public Set<Map.Entry<Interval<K>, V>> entrySet() {
// TODO Auto-generated method stub
return null;
}

public V get(Object key) {
// TODO Auto-generated method stub
return null;
}

public boolean isEmpty() {
// TODO Auto-generated method stub
return false;
}

public Set<Interval<K>> keySet() {
// TODO Auto-generated method stub
return null;
}

public V put(Interval<K> key, V value) {
// TODO Auto-generated method stub
return null;
}

public void putAll(Map<? extends Interval<K>, ? extends V> m) {
// TODO Auto-generated method stub

}

public V remove(Object key) {
// TODO Auto-generated method stub
return null;
}

public int size() {
// TODO Auto-generated method stub
return 0;
}

public Collection<V> values() {
// TODO Auto-generated method stub
return null;
}

}
58 changes: 58 additions & 0 deletions src/test/java/org/sugis/intervalmap/IntervalTestCase.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package org.sugis.intervalmap;

import junit.framework.TestCase;

/**
* Test case for the Interval class
* @see Interval
* @author Steven Schlansker
*/
public class IntervalTestCase extends TestCase {

private Interval<Integer> test1 = new Interval<Integer>(1, 5),
test2 = new Interval<Integer>(4, 6),
test3 = new Interval<Integer>(7, 10);

@Override
protected void setUp() throws Exception {
super.setUp();
}

/**
* Test hashCode method
* @see Interval#hashCode()
*/
public void testHashCode() {
fail("Not yet implemented");
}

/**
* Test getLowerBound
* @see Interval#getLowerBound()
*/
public void testGetLowerBound() {
fail("Not yet implemented");
}

/**
* Test getUpperBound
* @see Interval#getUpperBound()
*/
public void testGetUpperBound() {
fail("Not yet implemented");
}

/**
* Test equals
* @see Interval#equals(Object)
*/
public void testEqualsObject() {
fail("Not yet implemented");
}

public void testSwappedBounds() {
assertEquals(new Interval<Integer>(1, 10),
new Interval<Integer>(10,1));
}

}
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<?xml version="1.0" encoding="UTF-8" ?>
<testsuite failures="4" time="0.053" errors="0" skipped="0" tests="5" name="org.sugis.intervalmap.IntervalTestCase">
<properties>
<property name="java.vendor" value="Apple Inc."/>
<property name="localRepository" value="/Users/steven/.m2/repository"/>
<property name="sun.java.launcher" value="SUN_STANDARD"/>
<property name="sun.management.compiler" value="HotSpot 64-Bit Server Compiler"/>
<property name="env.SECURITYSESSIONID" value="327b33"/>
<property name="env.COLORFGBG" value="0;15"/>
<property name="os.name" value="Mac OS X"/>
<property name="sun.boot.class.path" value="/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Classes/jsfd.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Classes/classes.jar:/System/Library/Frameworks/JavaVM.framework/Frameworks/JavaRuntimeSupport.framework/Resources/Java/JavaRuntimeSupport.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Classes/ui.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Classes/laf.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Classes/sunrsasign.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Classes/jsse.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Classes/jce.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Classes/charsets.jar"/>
<property name="env.TMPDIR" value="/var/folders/Ll/LlT8Vh2YGX4c7vgvlmaJSk+++TI/-Tmp-/"/>
<property name="env.PWD" value="/Users/steven/Documents/workspace/IntervalMap"/>
<property name="env.LANG" value="en_US.utf-8"/>
<property name="java.vm.specification.vendor" value="Sun Microsystems Inc."/>
<property name="java.runtime.version" value="1.6.0_15-b03-219"/>
<property name="env.JAVA_MAIN_CLASS_40953" value="org.codehaus.classworlds.Launcher"/>
<property name="env.Apple_PubSub_Socket_Render" value="/tmp/launch-HdbE0P/Render"/>
<property name="env.DISPLAY" value="/tmp/launch-lpUh3x/:0"/>
<property name="user.name" value="steven"/>
<property name="env.USER" value="steven"/>
<property name="env.SHELL" value="/bin/zsh"/>
<property name="env.__CF_USER_TEXT_ENCODING" value="0x1F5:0:0"/>
<property name="awt.nativeDoubleBuffering" value="true"/>
<property name="env.PATH" value="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/opt/local/bin:/opt/local/lib/postgresql84/bin"/>
<property name="user.language" value="en"/>
<property name="env.LC_MONETARY" value="en_US.utf-8"/>
<property name="sun.boot.library.path" value="/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Libraries"/>
<property name="classworlds.conf" value="/usr/share/maven/bin/m2.conf"/>
<property name="env.LC_CTYPE" value="en_US.utf-8"/>
<property name="java.version" value="1.6.0_15"/>
<property name="user.timezone" value="America/Los_Angeles"/>
<property name="sun.arch.data.model" value="64"/>
<property name="http.nonProxyHosts" value="local|*.local|169.254/16|*.169.254/16"/>
<property name="java.endorsed.dirs" value="/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/lib/endorsed"/>
<property name="sun.cpu.isalist" value=""/>
<property name="sun.jnu.encoding" value="MacRoman"/>
<property name="file.encoding.pkg" value="sun.io"/>
<property name="env.SHLVL" value="1"/>
<property name="file.separator" value="/"/>
<property name="java.specification.name" value="Java Platform API Specification"/>
<property name="java.class.version" value="50.0"/>
<property name="user.country" value="US"/>
<property name="java.home" value="/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home"/>
<property name="java.vm.info" value="mixed mode"/>
<property name="env.LOGNAME" value="steven"/>
<property name="os.version" value="10.6.1"/>
<property name="path.separator" value=":"/>
<property name="java.vm.version" value="14.1-b02-90"/>
<property name="java.awt.printerjob" value="apple.awt.CPrinterJob"/>
<property name="env.TERM" value="xterm"/>
<property name="sun.io.unicode.encoding" value="UnicodeLittle"/>
<property name="awt.toolkit" value="apple.awt.CToolkit"/>
<property name="socksNonProxyHosts" value="local|*.local|169.254/16|*.169.254/16"/>
<property name="ftp.nonProxyHosts" value="local|*.local|169.254/16|*.169.254/16"/>
<property name="user.home" value="/Users/steven"/>
<property name="env.OLDPWD" value="/Users/steven/Documents/workspace/IntervalMap"/>
<property name="java.specification.vendor" value="Sun Microsystems Inc."/>
<property name="env.TERM_PROGRAM" value="iTerm.app"/>
<property name="java.library.path" value=".:/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java"/>
<property name="java.vendor.url" value="http://www.apple.com/"/>
<property name="env.LC_MESSAGES" value="en_US.utf-8"/>
<property name="java.vm.vendor" value="Apple Inc."/>
<property name="gopherProxySet" value="false"/>
<property name="maven.home" value="/usr/share/maven"/>
<property name="java.runtime.name" value="Java(TM) SE Runtime Environment"/>
<property name="java.class.path" value="/usr/share/maven/boot/classworlds-1.1.jar"/>
<property name="java.vm.specification.name" value="Java Virtual Machine Specification"/>
<property name="java.vm.specification.version" value="1.0"/>
<property name="sun.cpu.endian" value="little"/>
<property name="sun.os.patch.level" value="unknown"/>
<property name="env.HOME" value="/Users/steven"/>
<property name="surefire.test.class.path" value="/Users/steven/Documents/workspace/IntervalMap/target/test-classes:/Users/steven/Documents/workspace/IntervalMap/target/classes:/Users/steven/.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar:/Users/steven/.m2/repository/com/google/code/findbugs/jsr305/1.3.9/jsr305-1.3.9.jar:"/>
<property name="java.io.tmpdir" value="/var/folders/Ll/LlT8Vh2YGX4c7vgvlmaJSk+++TI/-Tmp-/"/>
<property name="java.vendor.url.bug" value="http://bugreport.apple.com/"/>
<property name="env.SSH_AUTH_SOCK" value="/tmp/launch-5MYBy9/Listeners"/>
<property name="env.COMMAND_MODE" value="legacy"/>
<property name="java.awt.graphicsenv" value="apple.awt.CGraphicsEnvironment"/>
<property name="os.arch" value="x86_64"/>
<property name="java.ext.dirs" value="/Library/Java/Extensions:/System/Library/Java/Extensions:/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/lib/ext"/>
<property name="user.dir" value="/Users/steven/Documents/workspace/IntervalMap"/>
<property name="mrj.version" value="1060.1.6.0_15-219"/>
<property name="line.separator" value="
"/>
<property name="java.vm.name" value="Java HotSpot(TM) 64-Bit Server VM"/>
<property name="env.LC_NUMERIC" value="en_US.utf-8"/>
<property name="env.EDITOR" value="nano"/>
<property name="basedir" value="/Users/steven/Documents/workspace/IntervalMap"/>
<property name="env.LC_TIME" value="en_US.utf-8"/>
<property name="file.encoding" value="MacRoman"/>
<property name="env.LC_COLLATE" value="en_US.utf-8"/>
<property name="java.specification.version" value="1.6"/>
</properties>
<testcase time="0.004" classname="org.sugis.intervalmap.IntervalTestCase" name="testHashCode">
<failure message="Not yet implemented" type="junit.framework.AssertionFailedError">junit.framework.AssertionFailedError: Not yet implemented
at junit.framework.Assert.fail(Assert.java:47)
at org.sugis.intervalmap.IntervalTestCase.testHashCode(IntervalTestCase.java:26)
</failure>
</testcase>
<testcase time="0" classname="org.sugis.intervalmap.IntervalTestCase" name="testGetLowerBound">
<failure message="Not yet implemented" type="junit.framework.AssertionFailedError">junit.framework.AssertionFailedError: Not yet implemented
at junit.framework.Assert.fail(Assert.java:47)
at org.sugis.intervalmap.IntervalTestCase.testGetLowerBound(IntervalTestCase.java:34)
</failure>
</testcase>
<testcase time="0" classname="org.sugis.intervalmap.IntervalTestCase" name="testGetUpperBound">
<failure message="Not yet implemented" type="junit.framework.AssertionFailedError">junit.framework.AssertionFailedError: Not yet implemented
at junit.framework.Assert.fail(Assert.java:47)
at org.sugis.intervalmap.IntervalTestCase.testGetUpperBound(IntervalTestCase.java:42)
</failure>
</testcase>
<testcase time="0" classname="org.sugis.intervalmap.IntervalTestCase" name="testEqualsObject">
<failure message="Not yet implemented" type="junit.framework.AssertionFailedError">junit.framework.AssertionFailedError: Not yet implemented
at junit.framework.Assert.fail(Assert.java:47)
at org.sugis.intervalmap.IntervalTestCase.testEqualsObject(IntervalTestCase.java:50)
</failure>
</testcase>
<testcase time="0" classname="org.sugis.intervalmap.IntervalTestCase" name="testSwappedBounds"/>
</testsuite>
24 changes: 24 additions & 0 deletions target/surefire-reports/org.sugis.intervalmap.IntervalTestCase.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
-------------------------------------------------------------------------------
Test set: org.sugis.intervalmap.IntervalTestCase
-------------------------------------------------------------------------------
Tests run: 5, Failures: 4, Errors: 0, Skipped: 0, Time elapsed: 0.061 sec <<< FAILURE!
testHashCode(org.sugis.intervalmap.IntervalTestCase) Time elapsed: 0.007 sec <<< FAILURE!
junit.framework.AssertionFailedError: Not yet implemented
at junit.framework.Assert.fail(Assert.java:47)
at org.sugis.intervalmap.IntervalTestCase.testHashCode(IntervalTestCase.java:26)

testGetLowerBound(org.sugis.intervalmap.IntervalTestCase) Time elapsed: 0.001 sec <<< FAILURE!
junit.framework.AssertionFailedError: Not yet implemented
at junit.framework.Assert.fail(Assert.java:47)
at org.sugis.intervalmap.IntervalTestCase.testGetLowerBound(IntervalTestCase.java:34)

testGetUpperBound(org.sugis.intervalmap.IntervalTestCase) Time elapsed: 0.002 sec <<< FAILURE!
junit.framework.AssertionFailedError: Not yet implemented
at junit.framework.Assert.fail(Assert.java:47)
at org.sugis.intervalmap.IntervalTestCase.testGetUpperBound(IntervalTestCase.java:42)

testEqualsObject(org.sugis.intervalmap.IntervalTestCase) Time elapsed: 0.001 sec <<< FAILURE!
junit.framework.AssertionFailedError: Not yet implemented
at junit.framework.Assert.fail(Assert.java:47)
at org.sugis.intervalmap.IntervalTestCase.testEqualsObject(IntervalTestCase.java:50)

Binary file not shown.

0 comments on commit bcb3205

Please sign in to comment.