/* ----------------------------------------------------------------------------
 * 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 com.robotraconteur;

public class map_subscriptionserviceinfo2 extends java.util.AbstractMap<WrappedServiceSubscriptionClientID, ServiceInfo2Wrapped> {
  private transient long swigCPtr;
  protected transient boolean swigCMemOwn;

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

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

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

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


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

  public boolean containsKey(java.lang.Object key) {
    if (!(key instanceof WrappedServiceSubscriptionClientID)) {
      return false;
    }

    return containsImpl((WrappedServiceSubscriptionClientID)key);
  }

  public ServiceInfo2Wrapped get(java.lang.Object key) {
    if (!(key instanceof WrappedServiceSubscriptionClientID)) {
      return null;
    }

    Iterator itr = find((WrappedServiceSubscriptionClientID) key);
    if (itr.isNot(end())) {
      return itr.getValue();
    }

    return null;
  }

  public ServiceInfo2Wrapped put(WrappedServiceSubscriptionClientID key, ServiceInfo2Wrapped value) {
    Iterator itr = find((WrappedServiceSubscriptionClientID) key);
    if (itr.isNot(end())) {
      ServiceInfo2Wrapped oldValue = itr.getValue();
      itr.setValue(value);
      return oldValue;
    } else {
      putUnchecked(key, value);
      return null;
    }
  }

  public ServiceInfo2Wrapped remove(java.lang.Object key) {
    if (!(key instanceof WrappedServiceSubscriptionClientID)) {
      return null;
    }

    Iterator itr = find((WrappedServiceSubscriptionClientID) key);
    if (itr.isNot(end())) {
      ServiceInfo2Wrapped oldValue = itr.getValue();
      removeUnchecked(itr);
      return oldValue;
    } else {
      return null;
    }
  }

  public java.util.Set<Entry<WrappedServiceSubscriptionClientID, ServiceInfo2Wrapped>> entrySet() {
    java.util.Set<Entry<WrappedServiceSubscriptionClientID, ServiceInfo2Wrapped>> setToReturn =
        new java.util.HashSet<Entry<WrappedServiceSubscriptionClientID, ServiceInfo2Wrapped>>();

    Iterator itr = begin();
    final Iterator end = end();
    while (itr.isNot(end)) {
      setToReturn.add(new Entry<WrappedServiceSubscriptionClientID, ServiceInfo2Wrapped>() {
        private Iterator iterator;

        private Entry<WrappedServiceSubscriptionClientID, ServiceInfo2Wrapped> init(Iterator iterator) {
          this.iterator = iterator;
          return this;
        }

        public WrappedServiceSubscriptionClientID getKey() {
          return iterator.getKey();
        }

        public ServiceInfo2Wrapped getValue() {
          return iterator.getValue();
        }

        public ServiceInfo2Wrapped setValue(ServiceInfo2Wrapped newValue) {
          ServiceInfo2Wrapped oldValue = iterator.getValue();
          iterator.setValue(newValue);
          return oldValue;
        }
      }.init(itr));
      itr = itr.getNextUnchecked();
    }

    return setToReturn;
  }

  public map_subscriptionserviceinfo2() {
    this(RobotRaconteurJavaJNI.new_map_subscriptionserviceinfo2__SWIG_0(), true);
  }

  public map_subscriptionserviceinfo2(map_subscriptionserviceinfo2 other) {
    this(RobotRaconteurJavaJNI.new_map_subscriptionserviceinfo2__SWIG_1(map_subscriptionserviceinfo2.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;
    }
  
    @SuppressWarnings("deprecation")
    protected void finalize() {
      delete();
    }
  
    public synchronized void delete() {
      if (swigCPtr != 0) {
        if (swigCMemOwn) {
          swigCMemOwn = false;
          RobotRaconteurJavaJNI.delete_map_subscriptionserviceinfo2_Iterator(swigCPtr);
        }
        swigCPtr = 0;
      }
    }
  
    private map_subscriptionserviceinfo2.Iterator getNextUnchecked() {
      return new map_subscriptionserviceinfo2.Iterator(RobotRaconteurJavaJNI.map_subscriptionserviceinfo2_Iterator_getNextUnchecked(swigCPtr, this), true);
    }
  
    private boolean isNot(map_subscriptionserviceinfo2.Iterator other) {
      return RobotRaconteurJavaJNI.map_subscriptionserviceinfo2_Iterator_isNot(swigCPtr, this, map_subscriptionserviceinfo2.Iterator.getCPtr(other), other);
    }
  
    private WrappedServiceSubscriptionClientID getKey() {
      return new WrappedServiceSubscriptionClientID(RobotRaconteurJavaJNI.map_subscriptionserviceinfo2_Iterator_getKey(swigCPtr, this), true);
    }
  
    private ServiceInfo2Wrapped getValue() {
      return new ServiceInfo2Wrapped(RobotRaconteurJavaJNI.map_subscriptionserviceinfo2_Iterator_getValue(swigCPtr, this), true);
    }
  
    private void setValue(ServiceInfo2Wrapped newValue) {
      RobotRaconteurJavaJNI.map_subscriptionserviceinfo2_Iterator_setValue(swigCPtr, this, ServiceInfo2Wrapped.getCPtr(newValue), newValue);
    }
  
  }

  public boolean isEmpty() {
    return RobotRaconteurJavaJNI.map_subscriptionserviceinfo2_isEmpty(swigCPtr, this);
  }

  public void clear() {
    RobotRaconteurJavaJNI.map_subscriptionserviceinfo2_clear(swigCPtr, this);
  }

  private map_subscriptionserviceinfo2.Iterator find(WrappedServiceSubscriptionClientID key) {
    return new map_subscriptionserviceinfo2.Iterator(RobotRaconteurJavaJNI.map_subscriptionserviceinfo2_find(swigCPtr, this, WrappedServiceSubscriptionClientID.getCPtr(key), key), true);
  }

  private map_subscriptionserviceinfo2.Iterator begin() {
    return new map_subscriptionserviceinfo2.Iterator(RobotRaconteurJavaJNI.map_subscriptionserviceinfo2_begin(swigCPtr, this), true);
  }

  private map_subscriptionserviceinfo2.Iterator end() {
    return new map_subscriptionserviceinfo2.Iterator(RobotRaconteurJavaJNI.map_subscriptionserviceinfo2_end(swigCPtr, this), true);
  }

  private int sizeImpl() {
    return RobotRaconteurJavaJNI.map_subscriptionserviceinfo2_sizeImpl(swigCPtr, this);
  }

  private boolean containsImpl(WrappedServiceSubscriptionClientID key) {
    return RobotRaconteurJavaJNI.map_subscriptionserviceinfo2_containsImpl(swigCPtr, this, WrappedServiceSubscriptionClientID.getCPtr(key), key);
  }

  private void putUnchecked(WrappedServiceSubscriptionClientID key, ServiceInfo2Wrapped value) {
    RobotRaconteurJavaJNI.map_subscriptionserviceinfo2_putUnchecked(swigCPtr, this, WrappedServiceSubscriptionClientID.getCPtr(key), key, ServiceInfo2Wrapped.getCPtr(value), value);
  }

  private void removeUnchecked(map_subscriptionserviceinfo2.Iterator itr) {
    RobotRaconteurJavaJNI.map_subscriptionserviceinfo2_removeUnchecked(swigCPtr, this, map_subscriptionserviceinfo2.Iterator.getCPtr(itr), itr);
  }

}
