changed byteSet from Collection to List so as to iterate by index
This commit is contained in:
@@ -19,6 +19,7 @@ package nodash.core;
|
||||
|
||||
import java.security.PublicKey;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import nodash.exceptions.NoAdapterException;
|
||||
import nodash.exceptions.NoSessionExpiredException;
|
||||
@@ -148,7 +149,7 @@ public interface NoAdapter {
|
||||
* should return an empty collection, not a null object.
|
||||
* @throws NoAdapterException
|
||||
*/
|
||||
public Collection<NoByteSet> pollNoByteSets(PublicKey address) throws NoAdapterException;
|
||||
public List<NoByteSet> pollNoByteSets(PublicKey address) throws NoAdapterException;
|
||||
|
||||
/**
|
||||
* Adds a single NoByteSet to the addressed PublicKey address.
|
||||
@@ -167,6 +168,6 @@ public interface NoAdapter {
|
||||
* @throws NoAdapterException - if the adapter is unable to add the list of NoByteSet objects to
|
||||
* the pool.
|
||||
*/
|
||||
public void addNoByteSets(Collection<NoByteSet> byteSets, PublicKey address)
|
||||
public void addNoByteSets(List<NoByteSet> byteSets, PublicKey address)
|
||||
throws NoAdapterException;
|
||||
}
|
||||
|
||||
@@ -43,8 +43,8 @@ import nodash.models.NoByteSet;
|
||||
import nodash.models.NoSession;
|
||||
|
||||
public class NoDefaultAdapter implements NoAdapter {
|
||||
private static Map<PublicKey, Collection<NoByteSet>> byteSets =
|
||||
new ConcurrentHashMap<PublicKey, Collection<NoByteSet>>();
|
||||
private static Map<PublicKey, List<NoByteSet>> byteSets =
|
||||
new ConcurrentHashMap<PublicKey, List<NoByteSet>>();
|
||||
private static Map<String, NoSession> sessions = new ConcurrentHashMap<String, NoSession>();
|
||||
private static Set<String> online = Collections
|
||||
.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
|
||||
@@ -200,13 +200,13 @@ public class NoDefaultAdapter implements NoAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<NoByteSet> pollNoByteSets(PublicKey address) {
|
||||
public List<NoByteSet> pollNoByteSets(PublicKey address) {
|
||||
if (byteSets.containsKey(address)) {
|
||||
Collection<NoByteSet> storedByteSets = byteSets.get(address);
|
||||
Collection<NoByteSet> result = new ArrayList<NoByteSet>();
|
||||
for (NoByteSet byteSet : storedByteSets) {
|
||||
result.add(byteSet);
|
||||
storedByteSets.remove(byteSet);
|
||||
List<NoByteSet> storedByteSets = byteSets.get(address);
|
||||
List<NoByteSet> result = new ArrayList<NoByteSet>();
|
||||
for (int x = 0; x < storedByteSets.size(); x++) {
|
||||
result.add(storedByteSets.get(0));
|
||||
storedByteSets.remove(0);
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
@@ -223,7 +223,7 @@ public class NoDefaultAdapter implements NoAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNoByteSets(Collection<NoByteSet> addedByteSets, PublicKey address) {
|
||||
public void addNoByteSets(List<NoByteSet> addedByteSets, PublicKey address) {
|
||||
if (addedByteSets == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user