changed byteSet from Collection to List so as to iterate by index

This commit is contained in:
Dave
2015-07-05 18:57:25 +02:00
parent 81f9361eda
commit 06fd5e9845
3 changed files with 15 additions and 14 deletions

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -34,7 +34,7 @@ public final class NoSession implements Serializable {
private NoState state;
private final long expiry;
private Collection<NoByteSet> incoming;
private List<NoByteSet> incoming;
private NoUser current;
private String uuid;
@@ -173,7 +173,7 @@ public final class NoSession implements Serializable {
return this.incoming;
}
public Collection<NoByteSet> getIncomingSafe() {
public List<NoByteSet> getIncomingSafe() {
return this.incoming;
}
@@ -193,7 +193,7 @@ public final class NoSession implements Serializable {
}
}
public void setIncoming(Collection<NoByteSet> incoming) {
public void setIncoming(List<NoByteSet> incoming) {
this.incoming = incoming;
}