/* ----------------------------------------------------------------------------
 * 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 net.openvpn.ovpn3;

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

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

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

  protected static long swigRelease(ClientAPI_ServerEntryVector 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;
        ovpncliJNI.delete_ClientAPI_ServerEntryVector(swigCPtr);
      }
      swigCPtr = 0;
    }
  }

  public ClientAPI_ServerEntryVector(ClientAPI_ServerEntry[] initialElements) {
    this();
    reserve(initialElements.length);

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

  public ClientAPI_ServerEntryVector(Iterable<ClientAPI_ServerEntry> initialElements) {
    this();
    for (ClientAPI_ServerEntry element : initialElements) {
      add(element);
    }
  }

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

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

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

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

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

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

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

  public ClientAPI_ServerEntryVector() {
    this(ovpncliJNI.new_ClientAPI_ServerEntryVector__SWIG_0(), true);
  }

  public ClientAPI_ServerEntryVector(ClientAPI_ServerEntryVector other) {
    this(ovpncliJNI.new_ClientAPI_ServerEntryVector__SWIG_1(ClientAPI_ServerEntryVector.getCPtr(other), other), true);
  }

  public long capacity() {
    return ovpncliJNI.ClientAPI_ServerEntryVector_capacity(swigCPtr, this);
  }

  public void reserve(long n) {
    ovpncliJNI.ClientAPI_ServerEntryVector_reserve(swigCPtr, this, n);
  }

  public boolean isEmpty() {
    return ovpncliJNI.ClientAPI_ServerEntryVector_isEmpty(swigCPtr, this);
  }

  public void clear() {
    ovpncliJNI.ClientAPI_ServerEntryVector_clear(swigCPtr, this);
  }

  public ClientAPI_ServerEntryVector(int count, ClientAPI_ServerEntry value) {
    this(ovpncliJNI.new_ClientAPI_ServerEntryVector__SWIG_2(count, ClientAPI_ServerEntry.getCPtr(value), value), true);
  }

  private int doSize() {
    return ovpncliJNI.ClientAPI_ServerEntryVector_doSize(swigCPtr, this);
  }

  private void doAdd(ClientAPI_ServerEntry x) {
    ovpncliJNI.ClientAPI_ServerEntryVector_doAdd__SWIG_0(swigCPtr, this, ClientAPI_ServerEntry.getCPtr(x), x);
  }

  private void doAdd(int index, ClientAPI_ServerEntry x) {
    ovpncliJNI.ClientAPI_ServerEntryVector_doAdd__SWIG_1(swigCPtr, this, index, ClientAPI_ServerEntry.getCPtr(x), x);
  }

  private ClientAPI_ServerEntry doRemove(int index) {
    return new ClientAPI_ServerEntry(ovpncliJNI.ClientAPI_ServerEntryVector_doRemove(swigCPtr, this, index), true);
  }

  private ClientAPI_ServerEntry doGet(int index) {
    return new ClientAPI_ServerEntry(ovpncliJNI.ClientAPI_ServerEntryVector_doGet(swigCPtr, this, index), false);
  }

  private ClientAPI_ServerEntry doSet(int index, ClientAPI_ServerEntry val) {
    return new ClientAPI_ServerEntry(ovpncliJNI.ClientAPI_ServerEntryVector_doSet(swigCPtr, this, index, ClientAPI_ServerEntry.getCPtr(val), val), true);
  }

  private void doRemoveRange(int fromIndex, int toIndex) {
    ovpncliJNI.ClientAPI_ServerEntryVector_doRemoveRange(swigCPtr, this, fromIndex, toIndex);
  }

}
