Package r.data.RArray

Examples of r.data.RArray.Names


        public RLogical cmp(RString a, RString b, ASTNode ast) {
            int na = a.size();
            int nb = b.size();
            int[] dimensions = Arithmetic.resultDimensions(ast, a, b);
            Names names = Arithmetic.resultNames(ast, a, b);
            if (na == 0 || nb == 0) {
                return RLogical.EMPTY;
            }

            int n = (na > nb) ? na : nb;
View Full Code Here


        }
        public RLogical cmp(RComplex a, RComplex b, ASTNode ast) {
            int na = a.size();
            int nb = b.size();
            int[] dimensions = Arithmetic.resultDimensions(ast, a, b);
            Names names = Arithmetic.resultNames(ast, a, b);
            if (na == 0 || nb == 0) {
                return RLogical.EMPTY;
            }

            int n = (na > nb) ? na : nb;
View Full Code Here

        public RLogical cmp(RDouble a, RDouble b, ASTNode ast) {
            int na = a.size();
            int nb = b.size();
            int[] dimensions = Arithmetic.resultDimensions(ast, a, b);
            Names names = Arithmetic.resultNames(ast, a, b);
            if (na == 0 || nb == 0) {
                return RLogical.EMPTY;
            }

            int n = (na > nb) ? na : nb;
View Full Code Here

        }
        public RLogical cmp(RInt a, RInt b, ASTNode ast) {
            int na = a.size();
            int nb = b.size();
            int[] dimensions = Arithmetic.resultDimensions(ast, a, b);
            Names names = Arithmetic.resultNames(ast, a, b);

            if (na == 0 || nb == 0) {
                return RLogical.EMPTY;
            }
View Full Code Here

        }
        public RLogical cmp(RLogical a, RLogical b, ASTNode ast) {
            int na = a.size();
            int nb = b.size();
            int[] dimensions = Arithmetic.resultDimensions(ast, a, b);
            Names names = Arithmetic.resultNames(ast, a, b);

            if (na == 0 || nb == 0) {
                return RLogical.EMPTY;
            }
View Full Code Here

        }
        public RLogical cmp(RRaw a, RRaw b, ASTNode ast) {
            int na = a.size();
            int nb = b.size();
            int[] dimensions = Arithmetic.resultDimensions(ast, a, b);
            Names names = Arithmetic.resultNames(ast, a, b);

            if (na == 0 || nb == 0) {
                return RLogical.EMPTY;
            }
View Full Code Here

        public static RAny deleteElements(RList base, RLogical index, @SuppressWarnings("unused") ASTNode ast) {
            int bsize = base.size();
            int isize = index.size();

            Names names = base.names();
            RSymbol[] symbols = names == null ? null : names.sequence();
            if (isize == bsize) {
                int ntrue = RLogical.RLogicalUtils.truesInRange(index, 0, isize);
                int nsize = bsize - ntrue;
                RAny[] content = new RAny[nsize];
                RSymbol[] nsymbols = symbols == null ? null : new RSymbol[nsize];
View Full Code Here

            int bsize = base.size();
            int isize = index.size();
            int vsize = typedValue != null ? typedValue.size() : listValue.size();
            int nsize;
            RArray res;
            Names names = base.names();
            boolean expanding;
            if (isize <= bsize) {
                nsize = bsize;
                expanding = false;
                res = Utils.createArray(typedBase, nsize, dimensions, names, base.attributesRef());
View Full Code Here

    }

    public static class StringSelection {

        public static RAny deleteElements(RList base, RString index, @SuppressWarnings("unused") ASTNode ast) {
            Names bnames = base.names();
            if (bnames == null) { return Utils.dropDimensions(base); }
            int bsize = base.size();
            int isize = index.size();
            boolean[] remove = new boolean[bsize];
            int nremove = 0;

            for (int i = 0; i < isize; i++) {
                RSymbol s = RSymbol.getSymbol(index.getString(i));
                int v = bnames.map(s);
                if (v != -1) {
                    if (!remove[v]) {
                        remove[v] = true;
                        nremove++;
                    }
                }
            }

            if (nremove == 0) { return base; }
            int nsize = bsize - nremove;
            RSymbol[] bsymbols = bnames.sequence();
            RSymbol[] nsymbols = new RSymbol[nsize];
            RAny[] content = new RAny[nsize];
            int j = 0;
            for (int i = 0; i < bsize; i++) {
                if (!remove[i]) { // shallow copy
View Full Code Here

            int vsize = typedValue != null ? typedValue.size() : listValue.size();

            // note that the base can have duplicate names, even though these cannot be created using update vector (like here),
            // they can be created e.g. using names<- or with the c() builtin

            Names bnames = base.names();
            RSymbol[] bsymbols;
            HashMap<RSymbol, Integer> nmap;
            if (bnames == null) {
                nmap = new HashMap<>(bsize);
                bsymbols = null;
            } else {
                assert Utils.check(Names.keepsMap()); // FIXME: re-visit this if we re-introduce names that don't carry hashmaps
                                                      // (probably should build a new one in such a case)
                nmap = new HashMap<>(bnames.getMap());
                bsymbols = bnames.sequence();
            }

            RSymbol[] addSymbols = new RSymbol[isize];
            int j = 0;
            // NOTE: targetOffsets is here to avoid double lookup via the hashmap
            // NOTE: firstOverwrite is here to make targetOffsets smaller in the quite common case that no (or little) new symbols are added
            int firstOverwrite = -1;
            int noverwrites = 0;
            int[] targetOffsets = null;
            for (int i = 0; i < isize; i++) {
                RSymbol name = RSymbol.getSymbol(index.getString(i));
                if (name == RSymbol.EMPTY_SYMBOL || name == RSymbol.NA_SYMBOL) { // these should never go to the map
                    addSymbols[j] = name;
                    if (targetOffsets != null) {
                        targetOffsets[i - firstOverwrite] = j + bsize;
                    }
                    j++;
                } else {
                    Integer prevOffset = nmap.get(name);
                    if (prevOffset == null) {
                        nmap.put(name, j + bsize);
                        addSymbols[j] = name;
                        if (targetOffsets != null) {
                            targetOffsets[i - firstOverwrite] = j + bsize;
                        }
                        j++;
                    } else {
                        if (firstOverwrite == -1) {
                            firstOverwrite = i;
                            targetOffsets = new int[isize - firstOverwrite];
                        }
                        noverwrites++;
                        targetOffsets[i - firstOverwrite] = prevOffset.intValue();
                    }
                }
            }

            int addSize = isize - noverwrites;
            int nsize = bsize + addSize;

            Names nnames;
            if (addSize == 0) {
                nnames = bnames;
            } else if (bsize == 0) {
                nnames = Names.create(addSymbols, nmap);
            } else {
View Full Code Here

TOP

Related Classes of r.data.RArray.Names

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.