Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions code/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,17 @@
<plugins>
<plugin>
<!--
Configure javac compiler for Java 6 compatibility.
Note that actually the library might also be compatible with Java 5, but this has not been tested.
Configure javac compiler for Java 5 compatibility.
-->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<source>1.5</source>
<target>1.5</target>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
<compilerArgument>-Xlint:all,-options,-processing</compilerArgument>
</configuration>
</plugin>
<plugin>
Expand All @@ -76,6 +78,9 @@
<archive>
<!-- This is required by bnd-maven-plugin -->
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
<manifestEntries>
<Automatic-Module-Name>${project.groupId}.${project.artifactId}</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
</plugin>
Expand Down Expand Up @@ -107,6 +112,27 @@
</execution>
</executions>
</plugin>
<plugin>
<!-- Make sure no APIs are included that are newer then Java 5 -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-maven-plugin</artifactId>
<version>1.16</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>check</goal>
</goals>
<configuration>
<signature>
<groupId>org.codehaus.mojo.signature</groupId>
<artifactId>java15</artifactId>
<version>1.0</version>
</signature>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Copyright 2012-2013 Niall Gallagher
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -15,12 +15,6 @@
*/
package com.googlecode.concurrenttrees.common;

import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.Charset;
import java.nio.charset.CharsetEncoder;
import java.nio.charset.CodingErrorAction;
import java.util.Iterator;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Copyright 2012-2013 Niall Gallagher
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Copyright 2012-2013 Niall Gallagher
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Copyright 2012-2013 Niall Gallagher
* Copyright 2007 The Guava Authors
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Copyright 2012-2013 Niall Gallagher
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -16,6 +16,7 @@
package com.googlecode.concurrenttrees.common;

import com.googlecode.concurrenttrees.radix.node.Node;
import com.googlecode.concurrenttrees.radix.node.NodeList;
import com.googlecode.concurrenttrees.radix.node.util.PrettyPrintable;

import java.io.IOException;
Expand Down Expand Up @@ -83,7 +84,7 @@ static void prettyPrint(Node node, Appendable sb, String prefix, boolean isTail,
StringBuilder label = new StringBuilder();
if (isRoot) {
label.append("○");
if (node.getIncomingEdge().length() > 0) {
if (node.getIncomingEdgeLength() > 0) {
label.append(" ");
}
}
Expand All @@ -92,7 +93,7 @@ static void prettyPrint(Node node, Appendable sb, String prefix, boolean isTail,
label.append(" (").append(node.getValue()).append(")");
}
sb.append(prefix).append(isTail ? isRoot ? "" : "└── ○ " : "├── ○ ").append(label).append("\n");
List<Node> children = node.getOutgoingEdges();
NodeList children = node.getOutgoingEdges();
for (int i = 0; i < children.size() - 1; i++) {
prettyPrint(children.get(i), sb, prefix + (isTail ? isRoot ? "" : " " : "│ "), false, false);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
/*
* Copyright 2012-2013 Niall Gallagher
*
* 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 com.googlecode.concurrenttrees.common;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.Serializable;
import java.util.*;

/**
* A facade implementation of a Java set for representing a Java map implementation.
*
* @param <E> The element type.
*/
public class SetFromMap<E> extends AbstractSet<E> implements Serializable {

private static final long serialVersionUID = 1L;

private final Map<E, Boolean> delegate;

private transient Set<E> keySet;

public SetFromMap(Map<E, Boolean> delegate) {
this.delegate = delegate;
keySet = delegate.keySet();
}

private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
stream.defaultReadObject();
keySet = delegate.keySet();
}

@Override
public int size() {
return delegate.size();
}

@Override
public boolean isEmpty() {
return delegate.isEmpty();
}

@Override
public boolean contains(Object o) {
return delegate.containsKey(o);
}

@Override
public boolean remove(Object o) {
return delegate.remove(o) != null;
}

@Override
public void clear() {
delegate.clear();
}

@Override
public boolean add(E e) {
return delegate.put(e, Boolean.TRUE) == null;
}

@Override
public Iterator<E> iterator() {
return keySet.iterator();
}

@Override
public Object[] toArray() {
return keySet.toArray();
}

@Override
public <T> T[] toArray(T[] a) {
return keySet.toArray(a);
}

@Override
public String toString() {
return keySet.toString();
}

@Override
public int hashCode() {
return keySet.hashCode();
}

@Override
public boolean equals(Object o) {
return o == this || keySet.equals(o);
}

@Override
public boolean containsAll(Collection<?> c) {
return keySet.containsAll(c);
}

@Override
public boolean removeAll(Collection<?> c) {
return keySet.removeAll(c);
}

@Override
public boolean retainAll(Collection<?> c) {
return keySet.retainAll(c);
}
}
Loading