/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (https://www.swig.org).
* Version 4.3.1
*
* Do not make changes to this file unless you know what you are doing - modify
* the SWIG interface file instead.
* ----------------------------------------------------------------------------- */
package com.inscoper.api;
import com.inscoper.api.logging.*;
public class UShortUCharMap extends java.util.AbstractMap<Integer, Short> {
private transient long swigCPtr;
protected transient boolean swigCMemOwn;
protected UShortUCharMap(long cPtr, boolean cMemoryOwn) {
swigCMemOwn = cMemoryOwn;
swigCPtr = cPtr;
}
protected static long getCPtr(UShortUCharMap obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}
protected static long swigRelease(UShortUCharMap 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", "removal"})
protected void finalize() {
delete();
}
public synchronized void delete() {
if (swigCPtr != 0) {
if (swigCMemOwn) {
swigCMemOwn = false;
InscoperJNI.delete_UShortUCharMap(swigCPtr);
}
swigCPtr = 0;
}
}
@Override
public int size() {
return sizeImpl();
}
@Override
public boolean isEmpty() {
return empty();
}
@Override
public void clear() {
doClear();
}
@Override
public boolean containsKey(java.lang.Object key) {
if (!(key instanceof Integer)) {
return false;
}
return containsImpl((Integer)key);
}
@Override
public Short get(java.lang.Object key) {
if (!(key instanceof Integer)) {
return null;
}
Iterator itr = find((Integer) key);
if (itr.isNot(end())) {
return itr.getValue();
}
return null;
}
@Override
public Short put(Integer key, Short value) {
Iterator itr = find(key);
if (itr.isNot(end())) {
Short oldValue = itr.getValue();
itr.setValue(value);
return oldValue;
} else {
putUnchecked(key, value);
return null;
}
}
@Override
public Short remove(java.lang.Object key) {
if (!(key instanceof Integer)) {
return null;
}
Iterator itr = find((Integer) key);
if (itr.isNot(end())) {
Short oldValue = itr.getValue();
removeUnchecked(itr);
return oldValue;
} else {
return null;
}
}
@Override
public java.util.Set<Entry<Integer, Short>> entrySet() {
java.util.Set<Entry<Integer, Short>> setToReturn =
new java.util.HashSet<>();
Iterator itr = begin();
final Iterator end = end();
while (itr.isNot(end)) {
setToReturn.add(new Entry<Integer, Short>() {
private Iterator iterator;
private Entry<Integer, Short> init(Iterator iterator) {
this.iterator = iterator;
return this;
}
@Override
public Integer getKey() {
return iterator.getKey();
}
@Override
public Short getValue() {
return iterator.getValue();
}
@Override
public Short setValue(Short newValue) {
Short oldValue = iterator.getValue();
iterator.setValue(newValue);
return oldValue;
}
}.init(itr));
itr = itr.getNextUnchecked();
}
return setToReturn;
}
public UShortUCharMap() {
this(InscoperJNI.new_UShortUCharMap__SWIG_0(), true);
}
public UShortUCharMap(UShortUCharMap other) {
this(InscoperJNI.new_UShortUCharMap__SWIG_1(UShortUCharMap.getCPtr(other), other), true);
}
static protected class Iterator {
private transient long swigCPtr;
protected transient boolean swigCMemOwn;
protected Iterator(long cPtr, boolean cMemoryOwn) {
swigCMemOwn = cMemoryOwn;
swigCPtr = cPtr;
}
protected static long getCPtr(Iterator obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}
protected static long swigRelease(Iterator 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", "removal"})
protected void finalize() {
delete();
}
public synchronized void delete() {
if (swigCPtr != 0) {
if (swigCMemOwn) {
swigCMemOwn = false;
InscoperJNI.delete_UShortUCharMap_Iterator(swigCPtr);
}
swigCPtr = 0;
}
}
private UShortUCharMap.Iterator getNextUnchecked() {
return new UShortUCharMap.Iterator(InscoperJNI.UShortUCharMap_Iterator_getNextUnchecked(swigCPtr, this), true);
}
private boolean isNot(UShortUCharMap.Iterator other) {
return InscoperJNI.UShortUCharMap_Iterator_isNot(swigCPtr, this, UShortUCharMap.Iterator.getCPtr(other), other);
}
private int getKey() {
return InscoperJNI.UShortUCharMap_Iterator_getKey(swigCPtr, this);
}
private short getValue() {
return InscoperJNI.UShortUCharMap_Iterator_getValue(swigCPtr, this);
}
private void setValue(short newValue) {
InscoperJNI.UShortUCharMap_Iterator_setValue(swigCPtr, this, newValue);
}
}
private boolean empty() {
return InscoperJNI.UShortUCharMap_empty(swigCPtr, this);
}
private void doClear() {
InscoperJNI.UShortUCharMap_doClear(swigCPtr, this);
}
private UShortUCharMap.Iterator find(int key) {
return new UShortUCharMap.Iterator(InscoperJNI.UShortUCharMap_find(swigCPtr, this, key), true);
}
private UShortUCharMap.Iterator begin() {
return new UShortUCharMap.Iterator(InscoperJNI.UShortUCharMap_begin(swigCPtr, this), true);
}
private UShortUCharMap.Iterator end() {
return new UShortUCharMap.Iterator(InscoperJNI.UShortUCharMap_end(swigCPtr, this), true);
}
private int sizeImpl() {
return InscoperJNI.UShortUCharMap_sizeImpl(swigCPtr, this);
}
private boolean containsImpl(int key) {
return InscoperJNI.UShortUCharMap_containsImpl(swigCPtr, this, key);
}
private void putUnchecked(int key, short value) {
InscoperJNI.UShortUCharMap_putUnchecked(swigCPtr, this, key, value);
}
private void removeUnchecked(UShortUCharMap.Iterator itr) {
InscoperJNI.UShortUCharMap_removeUnchecked(swigCPtr, this, UShortUCharMap.Iterator.getCPtr(itr), itr);
}
}