/* ----------------------------------------------------------------------------
 * 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.seantone.sxtwl;

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

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

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

  protected static long swigRelease(JQList 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;
        sxtwlJNI.delete_JQList(swigCPtr);
      }
      swigCPtr = 0;
    }
  }

  public JQList(JieQiInfo[] initialElements) {
    this();
    reserve(initialElements.length);

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

  public JQList(Iterable<JieQiInfo> initialElements) {
    this();
    for (JieQiInfo element : initialElements) {
      add(element);
    }
  }

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

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

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

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

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

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

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

  public JQList() {
    this(sxtwlJNI.new_JQList__SWIG_0(), true);
  }

  public JQList(JQList other) {
    this(sxtwlJNI.new_JQList__SWIG_1(JQList.getCPtr(other), other), true);
  }

  public long capacity() {
    return sxtwlJNI.JQList_capacity(swigCPtr, this);
  }

  public void reserve(long n) {
    sxtwlJNI.JQList_reserve(swigCPtr, this, n);
  }

  public boolean isEmpty() {
    return sxtwlJNI.JQList_isEmpty(swigCPtr, this);
  }

  public void clear() {
    sxtwlJNI.JQList_clear(swigCPtr, this);
  }

  public JQList(int count, JieQiInfo value) {
    this(sxtwlJNI.new_JQList__SWIG_2(count, JieQiInfo.getCPtr(value), value), true);
  }

  private int doSize() {
    return sxtwlJNI.JQList_doSize(swigCPtr, this);
  }

  private void doAdd(JieQiInfo x) {
    sxtwlJNI.JQList_doAdd__SWIG_0(swigCPtr, this, JieQiInfo.getCPtr(x), x);
  }

  private void doAdd(int index, JieQiInfo x) {
    sxtwlJNI.JQList_doAdd__SWIG_1(swigCPtr, this, index, JieQiInfo.getCPtr(x), x);
  }

  private JieQiInfo doRemove(int index) {
    return new JieQiInfo(sxtwlJNI.JQList_doRemove(swigCPtr, this, index), true);
  }

  private JieQiInfo doGet(int index) {
    return new JieQiInfo(sxtwlJNI.JQList_doGet(swigCPtr, this, index), false);
  }

  private JieQiInfo doSet(int index, JieQiInfo val) {
    return new JieQiInfo(sxtwlJNI.JQList_doSet(swigCPtr, this, index, JieQiInfo.getCPtr(val), val), true);
  }

  private void doRemoveRange(int fromIndex, int toIndex) {
    sxtwlJNI.JQList_doRemoveRange(swigCPtr, this, fromIndex, toIndex);
  }

}