/* ----------------------------------------------------------------------------
 * 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 SampledValueVector extends java.util.AbstractList<SampledValue> implements java.util.RandomAccess {
  private transient long swigCPtr;
  protected transient boolean swigCMemOwn;

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

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

  protected static long swigRelease(SampledValueVector 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_SampledValueVector(swigCPtr);
      }
      swigCPtr = 0;
    }
  }

  public SampledValueVector(SampledValue[] initialElements) {
    this();
    reserve(initialElements.length);

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

  public SampledValueVector(Iterable<SampledValue> initialElements) {
    this();
    for (SampledValue element : initialElements) {
      add(element);
    }
  }

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

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

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

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

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

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

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

  public SampledValueVector() {
    this(NanolibJNI.new_SampledValueVector__SWIG_0(), true);
  }

  public SampledValueVector(SampledValueVector other) {
    this(NanolibJNI.new_SampledValueVector__SWIG_1(SampledValueVector.getCPtr(other), other), true);
  }

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

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

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

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

  public SampledValueVector(int count, SampledValue value) {
    this(NanolibJNI.new_SampledValueVector__SWIG_2(count, SampledValue.getCPtr(value), value), true);
  }

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

  private void doAdd(SampledValue x) {
    NanolibJNI.SampledValueVector_doAdd__SWIG_0(swigCPtr, this, SampledValue.getCPtr(x), x);
  }

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

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

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

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

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

}
