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

package com.frostwire.jlibtorrent.swig;

public class bitfield {
  private transient long swigCPtr;
  protected transient boolean swigCMemOwn;

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

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

  protected static long swigRelease(bitfield 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;
  }

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

  public bitfield() {
    this(libtorrent_jni.new_bitfield__SWIG_0(), true);
  }

  public bitfield(int bits) {
    this(libtorrent_jni.new_bitfield__SWIG_1(bits), true);
  }

  public bitfield(int bits, boolean val) {
    this(libtorrent_jni.new_bitfield__SWIG_2(bits, val), true);
  }

  public bitfield(bitfield rhs) {
    this(libtorrent_jni.new_bitfield__SWIG_3(bitfield.getCPtr(rhs), rhs), true);
  }

  public boolean op_at(int index) {
    return libtorrent_jni.bitfield_op_at(swigCPtr, this, index);
  }

  public boolean get_bit(int index) {
    return libtorrent_jni.bitfield_get_bit(swigCPtr, this, index);
  }

  public void clear_bit(int index) {
    libtorrent_jni.bitfield_clear_bit(swigCPtr, this, index);
  }

  public void set_bit(int index) {
    libtorrent_jni.bitfield_set_bit(swigCPtr, this, index);
  }

  public boolean all_set() {
    return libtorrent_jni.bitfield_all_set(swigCPtr, this);
  }

  public boolean none_set() {
    return libtorrent_jni.bitfield_none_set(swigCPtr, this);
  }

  public int size() {
    return libtorrent_jni.bitfield_size(swigCPtr, this);
  }

  public int num_words() {
    return libtorrent_jni.bitfield_num_words(swigCPtr, this);
  }

  public boolean empty() {
    return libtorrent_jni.bitfield_empty(swigCPtr, this);
  }

  public void swap(bitfield rhs) {
    libtorrent_jni.bitfield_swap(swigCPtr, this, bitfield.getCPtr(rhs), rhs);
  }

  public int count() {
    return libtorrent_jni.bitfield_count(swigCPtr, this);
  }

  public int find_first_set() {
    return libtorrent_jni.bitfield_find_first_set(swigCPtr, this);
  }

  public int find_last_clear() {
    return libtorrent_jni.bitfield_find_last_clear(swigCPtr, this);
  }

  public void resize(int bits, boolean val) {
    libtorrent_jni.bitfield_resize__SWIG_0(swigCPtr, this, bits, val);
  }

  public void resize(int bits) {
    libtorrent_jni.bitfield_resize__SWIG_1(swigCPtr, this, bits);
  }

  public void set_all() {
    libtorrent_jni.bitfield_set_all(swigCPtr, this);
  }

  public void clear_all() {
    libtorrent_jni.bitfield_clear_all(swigCPtr, this);
  }

  public void clear() {
    libtorrent_jni.bitfield_clear(swigCPtr, this);
  }

  public bitfield(byte_vector v) {
    this(libtorrent_jni.new_bitfield__SWIG_4(byte_vector.getCPtr(v), v), true);
  }

  public void assign(byte_vector v) {
    libtorrent_jni.bitfield_assign(swigCPtr, this, byte_vector.getCPtr(v), v);
  }

}
