[Issue 480] New - Add high performance version of FunctionList

View: New views
3 Messages — Rating Filter:   Alert me  

[Issue 480] New - Add high performance version of FunctionList

by trumpetinc-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://glazedlists.dev.java.net/issues/show_bug.cgi?id=480
                 Issue #|480
                 Summary|Add high performance version of FunctionList
               Component|glazedlists
                 Version|0.9.1
                Platform|All
              OS/Version|All
                     URL|
                  Status|NEW
       Status whiteboard|
                Keywords|
              Resolution|
              Issue type|ENHANCEMENT
                Priority|P3
            Subcomponent|core
             Assigned to|jessewilson
             Reported by|trumpetinc






------- Additional comments from trumpetinc@... Fri Jul 10 14:19:15 +0000 2009 -------
Original question:

>We frequently find ourselves needing to perform relatively simple
> transformations on lists (for example, pull a value out of a
> composite object):
>
> class A{
>  public String val1;
>  public String val2;
> }
>
> with a pipeline of:
>
> EventList<A> -> FunctionList<A, String>
>
> so this is pretty simple, right? The Function implementation is
> actually boring it's so simple.
>
> What I'm wondering is if FunctionList is too heavyweight for this
> sort of scenario. It actually holds onto a full list of String
> objects, instead of just delegating the get() to the function. Every
> list mutation winds up with relatively expensive array adjustments.
> The function would have to be forward only, but I rarely find the
> need to do that in these scenarios.
>



and suggested implementation from Holger Brands on mailing list 6/7/09:

public class SimpleFunctionList<S, E> extends TransformedList<S, E> {
   private final Function<S,E> function;
   public SimpleFunctionList(EventList<S> source, Function<S,E> function) {
       super(source);
       this.function = function;
       source.addListEventListener(this);
   }
   public E get(int index) {
       final S elem = source.get(index);
       return function.evaluate(elem);
   }
   public void listChanged(ListEvent<S> listChanges) {
       updates.forwardEvent(listChanges);
   }
   protected boolean isWritable() {
       return false;
   }
}

.. and used like this for the above example:

   final EventList<Issue> issues = ...
   final Function<Issue, String> function =
GlazedLists.beanFunction(Issue.class, "reporter");
   final SimpleFunctionList<Issue, String> reporters = new
SimpleFunctionList<Issue, String>(issues, function);

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@...
For additional commands, e-mail: issues-help@...


[Issue 480] Add high performance version of FunctionList

by BRANDS-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://glazedlists.dev.java.net/issues/show_bug.cgi?id=480



User brands changed the following:

                What    |Old value                 |New value
================================================================================
             Assigned to|jessewilson               |brands
--------------------------------------------------------------------------------
        Target milestone|milestone 1               |1.9.0
--------------------------------------------------------------------------------




------- Additional comments from brands@... Sun Jul 19 20:43:18 +0000 2009 -------
reassigning...

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@...
For additional commands, e-mail: issues-help@...


[Issue 480] Add high performance version of FunctionList

by BRANDS-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://glazedlists.dev.java.net/issues/show_bug.cgi?id=480



User brands changed the following:

                What    |Old value                 |New value
================================================================================
                  Status|NEW                       |RESOLVED
--------------------------------------------------------------------------------
              Resolution|                          |FIXED
--------------------------------------------------------------------------------




------- Additional comments from brands@... Sun Jul 19 20:56:28 +0000 2009 -------
Added ca.odell.glazedlists.impl.SimpleFunctionList
and
GlazedLists#transformByFunction(EventList, Function)


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@...
For additional commands, e-mail: issues-help@...