/* ----------------------------------------------------------------------------
 * This file was automatically generated by SWIG (https://www.swig.org).
 * Version 4.1.1
 *
 * Do not make changes to this file unless you know what you are doing - modify
 * the SWIG interface file instead.
 * ----------------------------------------------------------------------------- */

package com.nanotec.nanolib;

public class SampleDataVector extends java.util.AbstractList<SampleData> implements java.util.RandomAccess {
  private transient long swigCPtr;
  protected transient boolean swigCMemOwn;

  protected SampleDataVector(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  protected static long getCPtr(SampleDataVector obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected static long swigRelease(SampleDataVector obj) {
    long ptr = 0;
    if (obj != null) {
      if (!obj.swigCMemOwn)
        throw new RuntimeException("Cannot release ownership as memory is not owned");
      ptr = obj.swigCPtr;
      obj.swigCMemOwn = false;
      obj.delete();
    }
    return ptr;
  }

  @SuppressWarnings("deprecation")
  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        NanolibJNI.delete_SampleDataVector(swigCPtr);
      }
      swigCPtr = 0;
    }
  }

  public SampleDataVector(SampleData[] initialElements) {
    this();
    reserve(initialElements.length);

    for (SampleData element : initialElements) {
      add(element);
    }
  }

  public SampleDataVector(Iterable<SampleData> initialElements) {
    this();
    for (SampleData element : initialElements) {
      add(element);
    }
  }

  public SampleData get(int index) {
    return doGet(index);
  }

  public SampleData set(int index, SampleData e) {
    return doSet(index, e);
  }

  public boolean add(SampleData e) {
    modCount++;
    doAdd(e);
    return true;
  }

  public void add(int index, SampleData e) {
    modCount++;
    doAdd(index, e);
  }

  public SampleData remove(int index) {
    modCount++;
    return doRemove(index);
  }

  protected void removeRange(int fromIndex, int toIndex) {
    modCount++;
    doRemoveRange(fromIndex, toIndex);
  }

  public int size() {
    return doSize();
  }

  public SampleDataVector() {
    this(NanolibJNI.new_SampleDataVector__SWIG_0(), true);
  }

  public SampleDataVector(SampleDataVector other) {
    this(NanolibJNI.new_SampleDataVector__SWIG_1(SampleDataVector.getCPtr(other), other), true);
  }

  public long capacity() {
    return NanolibJNI.SampleDataVector_capacity(swigCPtr, this);
  }

  public void reserve(long n) {
    NanolibJNI.SampleDataVector_reserve(swigCPtr, this, n);
  }

  public boolean isEmpty() {
    return NanolibJNI.SampleDataVector_isEmpty(swigCPtr, this);
  }

  public void clear() {
    NanolibJNI.SampleDataVector_clear(swigCPtr, this);
  }

  public SampleDataVector(int count, SampleData value) {
    this(NanolibJNI.new_SampleDataVector__SWIG_2(count, SampleData.getCPtr(value), value), true);
  }

  private int doSize() {
    return NanolibJNI.SampleDataVector_doSize(swigCPtr, this);
  }

  private void doAdd(SampleData x) {
    NanolibJNI.SampleDataVector_doAdd__SWIG_0(swigCPtr, this, SampleData.getCPtr(x), x);
  }

  private void doAdd(int index, SampleData x) {
    NanolibJNI.SampleDataVector_doAdd__SWIG_1(swigCPtr, this, index, SampleData.getCPtr(x), x);
  }

  private SampleData doRemove(int index) {
    return new SampleData(NanolibJNI.SampleDataVector_doRemove(swigCPtr, this, index), true);
  }

  private SampleData doGet(int index) {
    return new SampleData(NanolibJNI.SampleDataVector_doGet(swigCPtr, this, index), false);
  }

  private SampleData doSet(int index, SampleData val) {
    return new SampleData(NanolibJNI.SampleDataVector_doSet(swigCPtr, this, index, SampleData.getCPtr(val), val), true);
  }

  private void doRemoveRange(int fromIndex, int toIndex) {
    NanolibJNI.SampleDataVector_doRemoveRange(swigCPtr, this, fromIndex, toIndex);
  }

}
