Addressbook: Use new NamingService API methods in action handling

- Refactor HostTxtEntry to consolidate properties writing
- More HostTxtEntry tests
- Start of 'remove' entry handling
Blockfile: Cleanup unused code
- Add Iterable interface to SkipList
This commit is contained in:
zzz
2016-04-21 14:37:38 +00:00
parent 34e390909e
commit 4f262f6140
6 changed files with 159 additions and 197 deletions

View File

@ -206,6 +206,7 @@ public class BSkipList<K extends Comparable<? super K>, V> extends SkipList<K, V
return new IBSkipIterator<K, V>(first, 0);
}
/****
@Override
public SkipIterator<K, V> min() {
return iterator();
@ -218,6 +219,7 @@ public class BSkipList<K extends Comparable<? super K>, V> extends SkipList<K, V
SkipSpan<K, V> ss = stack.getEnd();
return new IBSkipIterator<K, V>(ss, ss.nKeys - 1);
}
****/
@Override
public SkipIterator<K, V> find(K key) {

View File

@ -1,59 +0,0 @@
/*
Copyright (c) 2006, Matthew Estes
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Metanotion Software nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.metanotion.io.data;
import net.metanotion.io.Serializer;
public class LongBytes implements Serializer<Long> {
public byte[] getBytes(Long o) {
byte[] b = new byte[8];
long v = o.longValue();
b[0] = (byte)(0xff & (v >> 56));
b[1] = (byte)(0xff & (v >> 48));
b[2] = (byte)(0xff & (v >> 40));
b[3] = (byte)(0xff & (v >> 32));
b[4] = (byte)(0xff & (v >> 24));
b[5] = (byte)(0xff & (v >> 16));
b[6] = (byte)(0xff & (v >> 8));
b[7] = (byte)(0xff & v);
return b;
}
public Long construct(byte[] b) {
long v =(((long)(b[0] & 0xff) << 56) |
((long)(b[1] & 0xff) << 48) |
((long)(b[2] & 0xff) << 40) |
((long)(b[3] & 0xff) << 32) |
((long)(b[4] & 0xff) << 24) |
((long)(b[5] & 0xff) << 16) |
((long)(b[6] & 0xff) << 8) |
(b[7] & 0xff));
return Long.valueOf(v);
}
}

View File

@ -35,7 +35,7 @@ import net.i2p.util.RandomSource;
//import net.metanotion.io.block.BlockFile;
public class SkipList<K extends Comparable<? super K>, V> implements Flushable {
public class SkipList<K extends Comparable<? super K>, V> implements Flushable, Iterable<V> {
/** the probability of each next higher level */
protected static final int P = 2;
private static final int MIN_SLOTS = 4;
@ -151,6 +151,7 @@ public class SkipList<K extends Comparable<? super K>, V> implements Flushable {
* dumps all the data
* @deprecated goes to System.out
*/
@Deprecated
public void print() {
System.out.println("List size " + size);
System.out.println(first.print());
@ -163,12 +164,14 @@ public class SkipList<K extends Comparable<? super K>, V> implements Flushable {
public SkipIterator<K, V> iterator() { return new SkipIterator<K, V>(first, 0); }
/****
public SkipIterator<K, V> min() { return new SkipIterator<K, V>(first, 0); }
public SkipIterator<K, V> max() {
SkipSpan<K, V> ss = stack.getEnd();
return new SkipIterator<K, V>(ss, ss.nKeys - 1);
}
****/
/** @return an iterator where nextKey() is the first one greater than or equal to 'key' */
public SkipIterator<K, V> find(K key) {
@ -178,7 +181,6 @@ public class SkipList<K extends Comparable<? super K>, V> implements Flushable {
return new SkipIterator<K, V>(ss, search[0]);
}
// Levels adjusted to guarantee O(log n) search
// This is expensive proportional to the number of spans.
public void balance() {