All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.gnode.nix.internal.VectorUtils Maven / Gradle / Ivy

The newest version!
package org.gnode.nix.internal;

import org.bytedeco.javacpp.DoublePointer;
import org.bytedeco.javacpp.IntPointer;
import org.bytedeco.javacpp.Loader;
import org.bytedeco.javacpp.Pointer;
import org.bytedeco.javacpp.annotation.*;
import org.gnode.nix.*;
import org.gnode.nix.valid.Message;

import java.util.ArrayList;
import java.util.List;

/**
 * 

VectorUtils

* Low level wrapper to std vectors. */ @Properties(value = { @Platform(include = { "", "", "", "", "", "", "", "", "", "", "", ""}, link = "nix", preload = "hdf5"), @Platform(value = "linux"), @Platform(value = "windows")}) public class VectorUtils { static { Loader.load(); } //-------------------------------------------------- // Block vector //-------------------------------------------------- /** *

BlockVector

* Low level std::vector<nix::Block> wrapper */ @Name("std::vector") public static class BlockVector extends Pointer { static { Loader.load(); } /** * Set blocks. * * @param lst list of blocks. * @see Block */ public BlockVector(List lst) { allocate(lst.size()); for (int i = 0; i < lst.size(); i++) { put(i, lst.get(i)); } } private native void allocate(@Cast("size_t") long n); private native long size(); @Index @ByRef private native Block get(@Cast("size_t") long i); private native BlockVector put(@Cast("size_t") long i, Block block); /** * Get blocks. * * @return list of blocks. * @see Block */ public List getBlocks() { ArrayList blocks = new ArrayList(); for (int i = 0; i < size(); i++) { blocks.add(get(i)); } return blocks; } } //-------------------------------------------------- // DataArray vector //-------------------------------------------------- /** *

DataArrayVector

* Low level std::vector<nix::DataArray> wrapper */ @Name("std::vector") public static class DataArrayVector extends Pointer { static { Loader.load(); } /** * Set data arrays. * * @param lst list of data arrays. * @see DataArray */ public DataArrayVector(List lst) { allocate(lst.size()); for (int i = 0; i < lst.size(); i++) { put(i, lst.get(i)); } } private native void allocate(@Cast("size_t") long n); private native long size(); @Index @ByRef private native DataArray get(@Cast("size_t") long i); private native DataArrayVector put(@Cast("size_t") long i, DataArray dataArray); /** * Get data arrays. * * @return list of data arrays. * @see DataArray */ public List getDataArrays() { ArrayList dataArrays = new ArrayList(); for (int i = 0; i < size(); i++) { dataArrays.add(get(i)); } return dataArrays; } } //-------------------------------------------------- // Dimension vector //-------------------------------------------------- /** *

DimensionVector

* Low level std::vector<nix::Dimension> wrapper */ @Name("std::vector") public static class DimensionVector extends Pointer { static { Loader.load(); } /** * Set dimensions. * * @param lst list of dimensions. * @see Dimension */ public DimensionVector(List lst) { allocate(lst.size()); for (int i = 0; i < lst.size(); i++) { put(i, lst.get(i)); } } private native void allocate(@Cast("size_t") long n); private native long size(); @Index @ByRef private native Dimension get(@Cast("size_t") long i); private native DimensionVector put(@Cast("size_t") long i, Dimension dimension); /** * Get dimensions. * * @return list of dimensions. * @see Dimension */ public List getDimensions() { ArrayList dimensions = new ArrayList(); for (int i = 0; i < size(); i++) { dimensions.add(get(i)); } return dimensions; } } //-------------------------------------------------- // Feature vector //-------------------------------------------------- /** *

FeatureVector

* Low level std::vector<nix::Feature> wrapper */ @Name("std::vector") public static class FeatureVector extends Pointer { static { Loader.load(); } /** * Set features. * * @param lst list of features. * @see Feature */ public FeatureVector(List lst) { allocate(lst.size()); for (int i = 0; i < lst.size(); i++) { put(i, lst.get(i)); } } private native void allocate(@Cast("size_t") long n); private native long size(); @Index @ByRef private native Feature get(@Cast("size_t") long i); private native FeatureVector put(@Cast("size_t") long i, Feature feature); /** * Get features. * * @return list of features. * @see Feature */ public List getFeatures() { ArrayList features = new ArrayList(); for (int i = 0; i < size(); i++) { features.add(get(i)); } return features; } } //-------------------------------------------------- // MultiTag vector //-------------------------------------------------- /** *

MultiTagVector

* Low level std::vector<nix::MultiTag> wrapper */ @Name("std::vector") public static class MultiTagVector extends Pointer { static { Loader.load(); } /** * Set multi tags. * * @param lst list of multi tags. * @see MultiTag */ public MultiTagVector(List lst) { allocate(lst.size()); for (int i = 0; i < lst.size(); i++) { put(i, lst.get(i)); } } private native void allocate(@Cast("size_t") long n); private native long size(); @Index @ByRef private native MultiTag get(@Cast("size_t") long i); private native MultiTagVector put(@Cast("size_t") long i, MultiTag multiTag); /** * Get multi tags. * * @return list of multi tags. * @see MultiTag */ public List getMultiTags() { ArrayList multiTags = new ArrayList(); for (int i = 0; i < size(); i++) { multiTags.add(get(i)); } return multiTags; } } //-------------------------------------------------- // Property vector //-------------------------------------------------- /** *

PropertyVector

* Low level std::vector<nix::Property> wrapper */ @Name("std::vector") public static class PropertyVector extends Pointer { static { Loader.load(); } /** * Set properties. * * @param lst list of properties. * @see Property */ public PropertyVector(List lst) { allocate(lst.size()); for (int i = 0; i < lst.size(); i++) { put(i, lst.get(i)); } } private native void allocate(@Cast("size_t") long n); private native long size(); @Index @ByRef private native Property get(@Cast("size_t") long i); private native PropertyVector put(@Cast("size_t") long i, Property property); /** * Get properties. * * @return list of properties. * @see Property */ public List getProperties() { ArrayList properties = new ArrayList(); for (int i = 0; i < size(); i++) { properties.add(get(i)); } return properties; } } //-------------------------------------------------- // Section vector //-------------------------------------------------- /** *

SectionVector

* Low level std::vector<nix::Section> wrapper */ @Name("std::vector") public static class SectionVector extends Pointer { static { Loader.load(); } /** * Set sections. * * @param lst list of sections. * @see Section */ public SectionVector(List
lst) { allocate(lst.size()); for (int i = 0; i < lst.size(); i++) { put(i, lst.get(i)); } } private native void allocate(@Cast("size_t") long n); private native long size(); @Index @ByRef private native Section get(@Cast("size_t") long i); private native SectionVector put(@Cast("size_t") long i, Section section); /** * Get sections. * * @return list of sections. * @see Section */ public List
getSections() { ArrayList
sections = new ArrayList
(); for (int i = 0; i < size(); i++) { sections.add(get(i)); } return sections; } } //-------------------------------------------------- // Source vector //-------------------------------------------------- /** *

SourceVector

* Low level std::vector<nix::Source> wrapper */ @Name("std::vector") public static class SourceVector extends Pointer { static { Loader.load(); } /** * Set sources. * * @param lst list of sources. * @see Source */ public SourceVector(List lst) { allocate(lst.size()); for (int i = 0; i < lst.size(); i++) { put(i, lst.get(i)); } } private native void allocate(@Cast("size_t") long n); private native long size(); @Index @ByRef private native Source get(@Cast("size_t") long i); private native SourceVector put(@Cast("size_t") long i, Source source); /** * Get source. * * @return list of sources. * @see Source */ public List getSources() { ArrayList sources = new ArrayList(); for (int i = 0; i < size(); i++) { sources.add(get(i)); } return sources; } } //-------------------------------------------------- // Tag vector //-------------------------------------------------- /** *

TagVector

* Low level std::vector<nix::Tag> wrapper */ @Name("std::vector") public static class TagVector extends Pointer { static { Loader.load(); } /** * Set tags. * * @param lst list of tags. * @see Tag */ public TagVector(List lst) { allocate(lst.size()); for (int i = 0; i < lst.size(); i++) { put(i, lst.get(i)); } } private native void allocate(@Cast("size_t") long n); private native long size(); @Index @ByRef private native Tag get(@Cast("size_t") long i); private native TagVector put(@Cast("size_t") long i, Tag tag); /** * Get tags. * * @return list of tags. * @see Tag */ public List getTags() { ArrayList tags = new ArrayList(); for (int i = 0; i < size(); i++) { tags.add(get(i)); } return tags; } } //-------------------------------------------------- // Value vector //-------------------------------------------------- /** *

ValueVector

* Low level std::vector<nix::Value> wrapper */ @Name("std::vector") public static class ValueVector extends Pointer { static { Loader.load(); } /** * Set values. * * @param lst list of values. * @see Value */ public ValueVector(List lst) { allocate(lst.size()); for (int i = 0; i < lst.size(); i++) { put(i, lst.get(i)); } } private native void allocate(@Cast("size_t") long n); private native long size(); @Index @ByRef private native Value get(@Cast("size_t") long i); private native ValueVector put(@Cast("size_t") long i, Value value); /** * Get values. * * @return list of values. * @see Value */ public List getValues() { ArrayList values = new ArrayList(); for (int i = 0; i < size(); i++) { values.add(get(i)); } return values; } } //-------------------------------------------------- // Message vector //-------------------------------------------------- /** *

MessageVector

* Low level std::vector<nix::valid::Message> wrapper */ @Name("std::vector") public static class MessageVector extends Pointer { static { Loader.load(); } /** * Set messages. * * @param lst list of messages. * @see Message */ public MessageVector(List lst) { allocate(lst.size()); for (int i = 0; i < lst.size(); i++) { put(i, lst.get(i)); } } private native void allocate(@Cast("size_t") long n); private native long size(); @Index @ByRef private native Message get(@Cast("size_t") long i); private native MessageVector put(@Cast("size_t") long i, Message message); /** * Get messages. * * @return list of messages. * @see Message */ public List getMessages() { ArrayList messages = new ArrayList(); for (int i = 0; i < size(); i++) { messages.add(get(i)); } return messages; } } //-------------------------------------------------- // String vector //-------------------------------------------------- /** *

StringVector

* Low level std::vector<std::string> wrapper */ @Name("std::vector") public static class StringVector extends Pointer { static { Loader.load(); } /** * Set list of strings. * * @param lst list of strings. * @see String */ public StringVector(List lst) { allocate(lst.size()); for (int i = 0; i < lst.size(); i++) { put(i, lst.get(i)); } } private native void allocate(@Cast("size_t") long n); private native long size(); @Index @ByRef private native String get(@Cast("size_t") long i); private native StringVector put(@Cast("size_t") long i, String value); /** * Get Strings. * * @return list of strings. * @see String */ public List getStrings() { ArrayList strings = new ArrayList(); for (int i = 0; i < size(); i++) { strings.add(get(i)); } return strings; } } //-------------------------------------------------- // IntPointer utilities //-------------------------------------------------- /** * Converts {@link IntPointer} to integer array * * @param ip {@link IntPointer} pointer to be converted * @return array of ints */ public static int[] convertPointerToArray(IntPointer ip) { int[] arr = null; if (ip != null) { arr = new int[ip.capacity()]; for (int i = 0; i < ip.capacity(); i++) { arr[i] = ip.get(i); } } return arr; } //-------------------------------------------------- // DoublePointer utilities //-------------------------------------------------- /** * Converts {@link DoublePointer} to double array. * * @param dp {@link DoublePointer} pointer to be converted * @return array of doubles */ public static double[] convertPointerToArray(DoublePointer dp) { double[] arr = null; if (dp != null) { arr = new double[dp.capacity()]; for (int i = 0; i < dp.capacity(); i++) { arr[i] = dp.get(i); } } return arr; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy