So does java.util.LinkedList.

Adrian Crum
Sandglass Software
www.sandglass-software.com

On 9/10/2014 10:43 AM, Jacques Le Roux wrote:
BTW, I just realise that FastList has getFirst() and getLast() methods
(only getLast() is used, twice in OFBiz code)

Jacques

Le 10/09/2014 11:05, Jacques Le Roux a écrit :
Actually I thought about it even before sending and I guess it's
because people are using an ASC or DESC sort in function of their
need, so getLast is not needed, agreed?

Jacques

Le 10/09/2014 09:53, Jacques Le Roux a écrit :
I want to introduce a getLast in EntityUtil class like we have getFirst
But I wonder if some of you are not doing it otherwise,  because I
find strange that it's not already there.

It would be:

--- a/framework/entity/src/org/ofbiz/entity/util/EntityUtil.java
+++ b/framework/entity/src/org/ofbiz/entity/util/EntityUtil.java
@@ -86,6 +86,26 @@ public class EntityUtil {
         }
     }

+    public static GenericValue getLast(Collection<GenericValue>
values) {
+        if (UtilValidate.isNotEmpty(values)) {
+            Iterator<GenericValue> itr = values.iterator();
+            GenericValue lastElement = itr.next();
+            while(itr.hasNext()) {
+                lastElement=itr.next();
+            }
+            return lastElement;
+        }
+        return null;
+    }
+
+    public static GenericValue getLast(List<GenericValue> values) {
+        if (UtilValidate.isNotEmpty(values)) {
+            return values.get(values.size() - 1);
+        } else {
+            return null;
+        }
+    }
+

Jacques


Reply via email to