On Thursday, 23 February 2012 at 01:36:32 UTC, Juan Manuel Cabo wrote:
On Thursday, 23 February 2012 at 00:51:38 UTC, Jonathan M Davis wrote:
[...]
If appender ends up with multiple arrays in it, then random access is no longer O(1) and is therefore unacceptable. As such, most sort algorithms wouldn't work with it.

If all I want is binary search on a big appender, then it
is O(k * n * log(n)), and that k right there doesn't
bother me. Also, binary search is absolutely not
cpu cache friendly to begin with.

Also, your bit about using appender to pass an array around wouldn't work either, because it wouldn't simply be wrapper
around an array anymore.

- Jonathan M Davis

Yeah, but I don't care about the underlying array. I care
about multiple places referencing the same Appender. If I
from any place that references it, it appends to the same
appender. The Appender "array" has identity. Ranges do not:

     int[] bla = [1,2,3];
     int[] ble = bla;
     ble ~= 4;
     assert(bla.length == 3);

This is very easy to solve with appender.
This is what happens in Java:
    ArrayList<Integer> bla = new ArrayList<Integer>();
    bla.add(1);
    ArrayList<Integer> ble = bla;
    ble.add(2);
    //prints 2
    System.out.println(Integer.toString(bla.size()));
    //prints 2
    System.out.println(Integer.toString(ble.size()));

(yikes, aint that verbose!)
The ArrayList has identity. It is a class, so that it
many variables reference the _same_ object.
(this can be accomplished with structs too though, but
not with ranges).

I meant ref counted structs.




P.S. Please don't top post. Replies should go _after_ the preceding message.

Sorry, got it.

--jm


Reply via email to