Package net.jcores.utils

Examples of net.jcores.utils.Folder


    public CoreObject<T> fold(final F2ReduceObjects<T> f, Option... options) {

        // In case we only have zero or one elements, don't do anything
        if (size() <= 1) return this;

        final Folder folder = new Folder(null, size()) {
            @Override
            public void handle(int i, int j, int destination) {
                // Get our target-array (if it is already there)
                T[] a = (T[]) this.array.get();

                // Get the in-value from the source-array
                final T ii = a[i];
                final T jj = a[j];

                if (ii == null && jj == null) return;
                if (ii == null && jj != null) {
                    a[destination] = jj;
                    return;
                }

                if (ii != null && jj == null) {
                    a[destination] = ii;
                    return;
                }

                a[destination] = f.f(ii, jj);
            }
        };

        // Update the target array and fold ...
        folder.updateArray(Arrays.copyOf(this.t, size()));

        // Now do fold ...
        fold(folder, options);

        // ... and return result.
        return new CoreObject<T>(this.commonCore, Arrays.copyOf((T[]) folder.getTargetArray(), 1));
    }
View Full Code Here

TOP

Related Classes of net.jcores.utils.Folder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.