< prev index next >

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

Print this page




  99 
 100     abstract void forEach(VectorMask<Byte> m, FUnCon f);
 101 
 102     // Static factories
 103 
 104     /**
 105      * Returns a vector where all lane elements are set to the default
 106      * primitive value.
 107      *
 108      * @param species species of desired vector
 109      * @return a zero vector of given species
 110      */
 111     @ForceInline
 112     @SuppressWarnings("unchecked")
 113     public static ByteVector zero(VectorSpecies<Byte> species) {
 114         return VectorIntrinsics.broadcastCoerced((Class<ByteVector>) species.vectorType(), byte.class, species.length(),
 115                                                  0, species,
 116                                                  ((bits, s) -> ((ByteSpecies)s).op(i -> (byte)bits)));
 117     }
 118 




















 119     /**
 120      * Loads a vector from a byte array starting at an offset.
 121      * <p>
 122      * Bytes are composed into primitive lane elements according to the
 123      * native byte order of the underlying platform
 124      * <p>
 125      * This method behaves as if it returns the result of calling the
 126      * byte buffer, offset, and mask accepting
 127      * {@link #fromByteBuffer(VectorSpecies, ByteBuffer, int, VectorMask) method} as follows:
 128      * <pre>{@code
 129      * return fromByteBuffer(species, ByteBuffer.wrap(a), offset, VectorMask.allTrue());
 130      * }</pre>
 131      *
 132      * @param species species of desired vector
 133      * @param a the byte array
 134      * @param offset the offset into the array
 135      * @return a vector loaded from a byte array
 136      * @throws IndexOutOfBoundsException if {@code i < 0} or
 137      * {@code offset > a.length - (species.length() * species.elementSize() / Byte.SIZE)}
 138      */




  99 
 100     abstract void forEach(VectorMask<Byte> m, FUnCon f);
 101 
 102     // Static factories
 103 
 104     /**
 105      * Returns a vector where all lane elements are set to the default
 106      * primitive value.
 107      *
 108      * @param species species of desired vector
 109      * @return a zero vector of given species
 110      */
 111     @ForceInline
 112     @SuppressWarnings("unchecked")
 113     public static ByteVector zero(VectorSpecies<Byte> species) {
 114         return VectorIntrinsics.broadcastCoerced((Class<ByteVector>) species.vectorType(), byte.class, species.length(),
 115                                                  0, species,
 116                                                  ((bits, s) -> ((ByteSpecies)s).op(i -> (byte)bits)));
 117     }
 118 
 119     @ForceInline
 120     @SuppressWarnings("unchecked")
 121     static VectorShuffle<Byte> shuffleIotaHelper(VectorSpecies<Byte> species, int step) {
 122         switch (species.bitSize()) {
 123             case 64: return VectorIntrinsics.shuffleIota(byte.class, Byte64Vector.Byte64Shuffle.class, species,
 124                                                         64 / Byte.SIZE, step,
 125                                                         (val, l) -> new Byte64Vector.Byte64Shuffle(i -> ((i + val) & (l-1))));
 126             case 128: return VectorIntrinsics.shuffleIota(byte.class, Byte128Vector.Byte128Shuffle.class, species,
 127                                                         128/ Byte.SIZE, step,
 128                                                         (val, l) -> new Byte128Vector.Byte128Shuffle(i -> ((i + val) & (l-1))));
 129             case 256: return VectorIntrinsics.shuffleIota(byte.class, Byte256Vector.Byte256Shuffle.class, species,
 130                                                         256/ Byte.SIZE, step,
 131                                                         (val, l) -> new Byte256Vector.Byte256Shuffle(i -> ((i + val) & (l-1))));
 132             case 512: return VectorIntrinsics.shuffleIota(byte.class, Byte512Vector.Byte512Shuffle.class, species,
 133                                                         512 / Byte.SIZE, step,
 134                                                         (val, l) -> new Byte512Vector.Byte512Shuffle(i -> ((i + val) & (l-1))));
 135             default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
 136         }
 137     }
 138 
 139     /**
 140      * Loads a vector from a byte array starting at an offset.
 141      * <p>
 142      * Bytes are composed into primitive lane elements according to the
 143      * native byte order of the underlying platform
 144      * <p>
 145      * This method behaves as if it returns the result of calling the
 146      * byte buffer, offset, and mask accepting
 147      * {@link #fromByteBuffer(VectorSpecies, ByteBuffer, int, VectorMask) method} as follows:
 148      * <pre>{@code
 149      * return fromByteBuffer(species, ByteBuffer.wrap(a), offset, VectorMask.allTrue());
 150      * }</pre>
 151      *
 152      * @param species species of desired vector
 153      * @param a the byte array
 154      * @param offset the offset into the array
 155      * @return a vector loaded from a byte array
 156      * @throws IndexOutOfBoundsException if {@code i < 0} or
 157      * {@code offset > a.length - (species.length() * species.elementSize() / Byte.SIZE)}
 158      */


< prev index next >