From 69296993e8d1e34f03057399e30ffdd7cfb126f7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 21 Sep 2011 07:46:39 +0200 Subject: [PATCH] Store images in a Map. --- src/main/java/net/pterodactylus/sone/data/Album.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/data/Album.java b/src/main/java/net/pterodactylus/sone/data/Album.java index 20862a4..7d22858 100644 --- a/src/main/java/net/pterodactylus/sone/data/Album.java +++ b/src/main/java/net/pterodactylus/sone/data/Album.java @@ -18,7 +18,9 @@ package net.pterodactylus.sone.data; import java.util.ArrayList; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import java.util.UUID; import net.pterodactylus.util.validation.Validation; @@ -40,7 +42,7 @@ public class Album implements Fingerprintable { private final List albums = new ArrayList(); /** The images in this album. */ - private final List images = new ArrayList(); + private final Map images = new LinkedHashMap(); /** The parent album. */ private Album parent; @@ -149,7 +151,7 @@ public class Album implements Fingerprintable { * @return The images in this album */ public List getImages() { - return new ArrayList(images); + return new ArrayList(images.values()); } /** @@ -164,8 +166,8 @@ public class Album implements Fingerprintable { image.getAlbum().removeImage(image); } image.setAlbum(this); - if (!images.contains(image)) { - images.add(image); + if (!images.containsKey(image.getId())) { + images.put(image.getId(), image); } } @@ -303,7 +305,7 @@ public class Album implements Fingerprintable { /* add images. */ fingerprint.append("Images("); - for (Image image : images) { + for (Image image : images.values()) { if (image.isInserted()) { fingerprint.append(image.getFingerprint()); } -- 2.7.4