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

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

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

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

  public OdIndexVector(OdIndex[] initialElements) {
    this();
    reserve(initialElements.length);

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

  public OdIndexVector(Iterable<OdIndex> initialElements) {
    this();
    for (OdIndex element : initialElements) {
      add(element);
    }
  }

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

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

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

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

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

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

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

  public OdIndexVector() {
    this(NanolibJNI.new_OdIndexVector__SWIG_0(), true);
  }

  public OdIndexVector(OdIndexVector other) {
    this(NanolibJNI.new_OdIndexVector__SWIG_1(OdIndexVector.getCPtr(other), other), true);
  }

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

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

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

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

  public OdIndexVector(int count, OdIndex value) {
    this(NanolibJNI.new_OdIndexVector__SWIG_2(count, OdIndex.getCPtr(value), value), true);
  }

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

  private void doAdd(OdIndex x) {
    NanolibJNI.OdIndexVector_doAdd__SWIG_0(swigCPtr, this, OdIndex.getCPtr(x), x);
  }

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

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

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

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

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

}
