add Inlist.appendList(), rename append() to appendItem()

This commit is contained in:
Hannes Janetzek 2013-09-25 02:19:42 +02:00
parent 3782ab8f57
commit 178f096b60
3 changed files with 38 additions and 8 deletions

View File

@ -87,7 +87,7 @@ public abstract class SpriteManager<T> {
}
Sprite sprite = new Sprite(item, mAtlas, r);
items = Inlist.append(items, sprite);
items = Inlist.appendItem(items, sprite);
draw(item, r);

View File

@ -30,7 +30,7 @@ public final class SymbolLayer extends TextureLayer {
private SymbolItem symbols;
public SymbolLayer() {
type = RenderElement.SYMBOL;
super(RenderElement.SYMBOL);
fixed = true;
}
@ -86,7 +86,7 @@ public final class SymbolLayer extends TextureLayer {
// clone TextureItem to use same texID with
// multiple TextureItem
to = TextureItem.clone(to);
textures = Inlist.append(textures, to);
textures = Inlist.appendItem(textures, to);
}
TextureAtlas.Rect r = it.texRegion.rect;
@ -104,7 +104,7 @@ public final class SymbolLayer extends TextureLayer {
// to.bitmap = it.bitmap;
// to.width = it.bitmap.getWidth();
// to.height = it.bitmap.getHeight();
textures = Inlist.append(textures, to);
textures = Inlist.appendItem(textures, to);
to.upload();
}
@ -190,7 +190,7 @@ public final class SymbolLayer extends TextureLayer {
for (to = prevTextures; to != null; to = to.next) {
if (to.bitmap == bitmap) {
prevTextures = Inlist.remove(prevTextures, to);
textures = Inlist.append(textures, to);
textures = Inlist.appendItem(textures, to);
break;
}
}

View File

@ -85,12 +85,11 @@ public class Inlist<T extends Inlist<T>> {
return item;
}
public static <T extends Inlist<T>> T append(T list, T item) {
public static <T extends Inlist<T>> T appendItem(T list, T item) {
if (debug) {
if (item.next != null) {
// warn
item.next = null;
throw new IllegalArgumentException("item is list");
}
}
@ -107,6 +106,37 @@ public class Inlist<T extends Inlist<T>> {
return list;
}
public static <T extends Inlist<T>> T appendList(T list, T list2) {
if (list == null)
return list2;
if (list == list2)
return list;
Inlist<T> it = list;
while (it.next != null) {
if (it.next == list2)
// hmmmm, already in list
return list;
it = it.next;
}
it.next = list2;
return list;
}
public static <T extends Inlist<T>> T last(T list) {
while (list != null) {
if (list.next == null)
return list;
list = list.next;
}
return null;
}
public static <T extends Inlist<T>> T prependRelative(T list, T item, T other) {
if (debug) {