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

package org.quantlib;

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

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

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

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

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

  public StochasticProcessVector(StochasticProcess[] initialElements) {
    this();
    reserve(initialElements.length);

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

  public StochasticProcessVector(Iterable<StochasticProcess> initialElements) {
    this();
    for (StochasticProcess element : initialElements) {
      add(element);
    }
  }

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

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

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

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

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

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

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

  public StochasticProcessVector() {
    this(QuantLibJNI.new_StochasticProcessVector__SWIG_0(), true);
  }

  public StochasticProcessVector(StochasticProcessVector other) {
    this(QuantLibJNI.new_StochasticProcessVector__SWIG_1(StochasticProcessVector.getCPtr(other), other), true);
  }

  public long capacity() {
    return QuantLibJNI.StochasticProcessVector_capacity(swigCPtr, this);
  }

  public void reserve(long n) {
    QuantLibJNI.StochasticProcessVector_reserve(swigCPtr, this, n);
  }

  public boolean isEmpty() {
    return QuantLibJNI.StochasticProcessVector_isEmpty(swigCPtr, this);
  }

  public void clear() {
    QuantLibJNI.StochasticProcessVector_clear(swigCPtr, this);
  }

  public StochasticProcessVector(int count, StochasticProcess value) {
    this(QuantLibJNI.new_StochasticProcessVector__SWIG_2(count, StochasticProcess.getCPtr(value), value), true);
  }

  private int doSize() {
    return QuantLibJNI.StochasticProcessVector_doSize(swigCPtr, this);
  }

  private void doAdd(StochasticProcess x) {
    QuantLibJNI.StochasticProcessVector_doAdd__SWIG_0(swigCPtr, this, StochasticProcess.getCPtr(x), x);
  }

  private void doAdd(int index, StochasticProcess x) {
    QuantLibJNI.StochasticProcessVector_doAdd__SWIG_1(swigCPtr, this, index, StochasticProcess.getCPtr(x), x);
  }

  private StochasticProcess doRemove(int index) {
    long cPtr = QuantLibJNI.StochasticProcessVector_doRemove(swigCPtr, this, index);
    return (cPtr == 0) ? null : new StochasticProcess(cPtr, true);
  }

  private StochasticProcess doGet(int index) {
    long cPtr = QuantLibJNI.StochasticProcessVector_doGet(swigCPtr, this, index);
    return (cPtr == 0) ? null : new StochasticProcess(cPtr, true);
  }

  private StochasticProcess doSet(int index, StochasticProcess val) {
    long cPtr = QuantLibJNI.StochasticProcessVector_doSet(swigCPtr, this, index, StochasticProcess.getCPtr(val), val);
    return (cPtr == 0) ? null : new StochasticProcess(cPtr, true);
  }

  private void doRemoveRange(int fromIndex, int toIndex) {
    QuantLibJNI.StochasticProcessVector_doRemoveRange(swigCPtr, this, fromIndex, toIndex);
  }

}
