< prev index next >

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorMask.java

Print this page

  1 /*
  2  * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.  Oracle designates this
  8  * particular file as subject to the "Classpath" exception as provided
  9  * by Oracle in the LICENSE file that accompanied this code.
 10  *
 11  * This code is distributed in the hope that it will be useful, but WITHOUT
 12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 14  * version 2 for more details (a copy is included in the LICENSE file that
 15  * accompanied this code).
 16  *
 17  * You should have received a copy of the GNU General Public License version
 18  * 2 along with this work; if not, write to the Free Software Foundation,
 19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 20  *
 21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 22  * or visit www.oracle.com if you need additional information or have any

499      *
500      * @apiNote For the sake of static type checking, users may wish
501      * to check the resulting vector against the expected integral
502      * lane type or species.  If the mask is for a float-point
503      * species, then the resulting vector will have the same shape and
504      * lane size, but an integral type.  If the mask is for an
505      * integral species, the resulting vector will be of exactly that
506      * species.
507      *
508      * @return a vector representation of this mask
509      * @see Vector#check(Class)
510      * @see Vector#check(VectorSpecies)
511      */
512     public abstract Vector<E> toVector();
513 
514     /**
515      * Tests if the lane at index {@code i} is set
516      * @param i the lane index
517      *
518      * @return true if the lane at index {@code i} is set, otherwise false


519      */
520     public abstract boolean laneIsSet(int i);
521 
522     /**
523      * Checks that this mask applies to vectors with the given element type,
524      * and returns this mask unchanged.
525      * The effect is similar to this pseudocode:
526      * {@code elementType == vectorSpecies().elementType()
527      *        ? this
528      *        : throw new ClassCastException()}.
529      *
530      * @param elementType the required lane type
531      * @param <F> the boxed element type of the required lane type
532      * @return the same mask
533      * @throws ClassCastException if the element type is wrong
534      * @see Vector#check(Class)
535      * @see VectorMask#check(VectorSpecies)
536      */
537     public abstract <F> VectorMask<F> check(Class<F> elementType);
538 
539     /**
540      * Checks that this mask has the given species,
541      * and returns this mask unchanged.
542      * The effect is similar to this pseudocode:
543      * {@code species == vectorSpecies()
544      *        ? this
545      *        : throw new ClassCastException()}.
546      *
547      * @param species vector species required for this mask
548      * @param <F> the boxed element type of the required species
549      * @return the same mask
550      * @throws ClassCastException if the species is wrong
551      * @see Vector#check(Class)
552      * @see Vector#check(VectorSpecies)
553      */
554     public abstract <F> VectorMask<F> check(VectorSpecies<F> species);
555 


















556     /**
557      * Returns a string representation of this mask, of the form
558      * {@code "Mask[T.TT...]"}, reporting the mask bit
559      * settings (as 'T' or '.' characters) in lane order.
560      *
561      * @return a string of the form {@code "Mask[T.TT...]"}
562      */
563     @Override
564     public final String toString() {
565         StringBuilder buf = new StringBuilder(length());
566         buf.append("Mask[");
567         for (boolean isSet : toArray()) {
568             buf.append(isSet ? 'T' : '.');
569         }
570         return buf.append(']').toString();
571     }
572 
573     /**
574      * Indicates whether this mask is identical to some other object.
575      * Two masks are identical only if they have the same species

  1 /*
  2  * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.  Oracle designates this
  8  * particular file as subject to the "Classpath" exception as provided
  9  * by Oracle in the LICENSE file that accompanied this code.
 10  *
 11  * This code is distributed in the hope that it will be useful, but WITHOUT
 12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 14  * version 2 for more details (a copy is included in the LICENSE file that
 15  * accompanied this code).
 16  *
 17  * You should have received a copy of the GNU General Public License version
 18  * 2 along with this work; if not, write to the Free Software Foundation,
 19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 20  *
 21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 22  * or visit www.oracle.com if you need additional information or have any

499      *
500      * @apiNote For the sake of static type checking, users may wish
501      * to check the resulting vector against the expected integral
502      * lane type or species.  If the mask is for a float-point
503      * species, then the resulting vector will have the same shape and
504      * lane size, but an integral type.  If the mask is for an
505      * integral species, the resulting vector will be of exactly that
506      * species.
507      *
508      * @return a vector representation of this mask
509      * @see Vector#check(Class)
510      * @see Vector#check(VectorSpecies)
511      */
512     public abstract Vector<E> toVector();
513 
514     /**
515      * Tests if the lane at index {@code i} is set
516      * @param i the lane index
517      *
518      * @return true if the lane at index {@code i} is set, otherwise false
519      * @throws IndexOutOfBoundsException if the index is out of range
520      * ({@code < 0 || >= length()})
521      */
522     public abstract boolean laneIsSet(int i);
523 
524     /**
525      * Checks that this mask applies to vectors with the given element type,
526      * and returns this mask unchanged.
527      * The effect is similar to this pseudocode:
528      * {@code elementType == vectorSpecies().elementType()
529      *        ? this
530      *        : throw new ClassCastException()}.
531      *
532      * @param elementType the required lane type
533      * @param <F> the boxed element type of the required lane type
534      * @return the same mask
535      * @throws ClassCastException if the element type is wrong
536      * @see Vector#check(Class)
537      * @see VectorMask#check(VectorSpecies)
538      */
539     public abstract <F> VectorMask<F> check(Class<F> elementType);
540 
541     /**
542      * Checks that this mask has the given species,
543      * and returns this mask unchanged.
544      * The effect is similar to this pseudocode:
545      * {@code species == vectorSpecies()
546      *        ? this
547      *        : throw new ClassCastException()}.
548      *
549      * @param species vector species required for this mask
550      * @param <F> the boxed element type of the required species
551      * @return the same mask
552      * @throws ClassCastException if the species is wrong
553      * @see Vector#check(Class)
554      * @see Vector#check(VectorSpecies)
555      */
556     public abstract <F> VectorMask<F> check(VectorSpecies<F> species);
557 
558     /**
559      * Checks that this mask has the same class with the given mask class,
560      * and it has the same species with given vector's species,
561      * and returns this mask unchanged.
562      * The effect is similar to this pseudocode:
563      * {@code getClass() == maskClass &&
564      *        vectorSpecies() == vector.species()
565      *        ? this
566      *        : throw new ClassCastException()}.
567      *
568      * @param maskClass the class required for this mask
569      * @param vector its species required for this mask
570      * @param <F> the boxed element type of the required species
571      * @return the same mask
572      * @throws ClassCastException if the species is wrong
573      */
574     abstract <F> VectorMask<F> check(Class<? extends VectorMask<F>> maskClass, Vector<F> vector);
575 
576     /**
577      * Returns a string representation of this mask, of the form
578      * {@code "Mask[T.TT...]"}, reporting the mask bit
579      * settings (as 'T' or '.' characters) in lane order.
580      *
581      * @return a string of the form {@code "Mask[T.TT...]"}
582      */
583     @Override
584     public final String toString() {
585         StringBuilder buf = new StringBuilder(length());
586         buf.append("Mask[");
587         for (boolean isSet : toArray()) {
588             buf.append(isSet ? 'T' : '.');
589         }
590         return buf.append(']').toString();
591     }
592 
593     /**
594      * Indicates whether this mask is identical to some other object.
595      * Two masks are identical only if they have the same species
< prev index next >