me respondo a mí mismo, pues me creé una estructura de datos experimental para paginar con maps:
Código Java:
Ver originalpackage app.contr.util;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.TreeMap;
public class PagesMap<K,V>
{
public enum Navegate {
goToFirst,
goToPrevious,
goToNext,
goToLast,
goToPresent
}
private final ArrayList
<LinkedHashMap
<K,V
>>pages
= new ArrayList(); private final int limit;
private int filas;
private int latest;
private int size;
private int page;
public PagesMap() {
this.limit = 10;
this.clear();
}
public PagesMap(int xlimit) {
this.limit = xlimit;
this.clear();
}
private LinkedHashMap<K,V> getNext() {
return (page == latest) ? getLast() : pages.get(++page);
}
private LinkedHashMap<K,V> getPrevious() {
return (page == 0) ? getFirst() : pages.get(--page);
}
private LinkedHashMap<K,V> getFirst() {
return (page != 0) ? pages.get((page = 0)) : pages.get((page = 0));
}
private LinkedHashMap<K,V> getLast() {
return (page != latest) ? pages.get((page = latest)) : pages.get((page = latest));
}
private LinkedHashMap<K,V> getPresent() {
return pages.get(page);
}
public LinkedHashMap<K,V> getReload(Navegate opcion) {
switch (opcion) {
case goToFirst:
getFirst();
break;
case goToPrevious:
getPrevious();
break;
case goToNext:
getNext();
break;
case goToLast:
getLast();
break;
}
return getPresent();
}
public final void clear() {
pages.clear();
this.page = 0;
this.filas = 0;
this.latest = 0;
LinkedHashMap<K,V> t = new LinkedHashMap();
pages.add(t);
this.size = 1;
}
public V put(K key,V value) {
if (key == null) {
}
else if (limit == filas) {
filas = 0;
LinkedHashMap<K,V> t = new LinkedHashMap();
pages.add(t);
latest++;
pages.get(latest).put(key, value);
size++;
filas++;
}
else{
pages.get(latest).put(key, value);
filas++;
}
return value;
}
public V get(K key){
for(LinkedHashMap<K,V> p : pages){
if(p.get(key) != null){
return p.get(key);
}
}
return null;
}
public boolean containsKey(K key){
for(LinkedHashMap<K,V> p : pages){
if(p.containsKey(key)){
return p.containsKey(key);
}
}
return false;
}
public boolean containsValue(V value){
for(LinkedHashMap<K,V> p : pages){
if(p.containsValue(value)){
return p.containsValue(value);
}
}
return false;
}
public V remove(K key) {
LinkedHashMap<K,V> aux = this.toMap();
V res = aux.get(key);
aux.remove(key);
this.clear();
aux.entrySet().stream().forEach((e) -> {
this.put(e.getKey(),e.getValue());
});
return res;
}
public LinkedHashMap<K,V> toMap() {
LinkedHashMap<K,V> aux = new LinkedHashMap();
pages.stream().forEach((list) -> {
list.entrySet().stream().forEach((row) -> {
aux.put(row.getKey(),row.getValue());
});
});
return aux;
}
public void sort(){
this.sort(null);
}
TreeMap
<K, V
> map
= new TreeMap(comp
); this.toMap().entrySet().stream().forEach((e) -> {
map.put(e.getKey(), e.getValue());
});
this.clear();
map.entrySet().stream().forEach((e) -> {
this.put(e.getKey(), e.getValue());
});
}
public PagesMap<K,V>copyTo(){
PagesMap<K,V> aux= new PagesMap(limit);
this.toMap().entrySet().stream().forEach((e) -> {
aux.put(e.getKey(), e.getValue());
});
return aux;
}
public boolean isEmpty(){
return size == 0;
}
public int size() {
return size;
}
}
por si a alguien le sirve el código, total esta es la versión experimental. Saludos