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

namespace clucene.net {

using System;
using System.Runtime.InteropServices;

public class Similarity : IDisposable {
  private HandleRef swigCPtr;
  protected bool swigCMemOwn;

  internal Similarity(IntPtr cPtr, bool cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = new HandleRef(this, cPtr);
  }

  internal static HandleRef getCPtr(Similarity obj) {
    return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
  }

  ~Similarity() {
    Dispose();
  }

  public virtual void Dispose() {
    if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) {
      swigCMemOwn = false;
      libCLcsharpPINVOKE.delete_Similarity(swigCPtr);
    }
    swigCPtr = new HandleRef(null, IntPtr.Zero);
    GC.SuppressFinalize(this);
  }

  public static void setDefault(Similarity similarity) {
    libCLcsharpPINVOKE.Similarity_setDefault(Similarity.getCPtr(similarity));
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
  }

  public static Similarity getDefault() {
    IntPtr cPtr = libCLcsharpPINVOKE.Similarity_getDefault();
    Similarity ret = (cPtr == IntPtr.Zero) ? null : new Similarity(cPtr, false);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public static byte encodeNorm(float f) {
    byte ret = libCLcsharpPINVOKE.Similarity_encodeNorm(f);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public static float decodeNorm(byte b) {
    double ret = libCLcsharpPINVOKE.Similarity_decodeNorm(b);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public static byte floatToByte(float f) {
    byte ret = libCLcsharpPINVOKE.Similarity_floatToByte(f);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public static float byteToFloat(byte b) {
    double ret = libCLcsharpPINVOKE.Similarity_byteToFloat(b);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public virtual float lengthNorm(string fieldName, int numTokens) {
    double ret = libCLcsharpPINVOKE.Similarity_lengthNorm(swigCPtr, fieldName, numTokens);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public virtual float queryNorm(float sumOfSquaredWeights) {
    double ret = libCLcsharpPINVOKE.Similarity_queryNorm(swigCPtr, sumOfSquaredWeights);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public virtual float sloppyFreq(int distance) {
    double ret = libCLcsharpPINVOKE.Similarity_sloppyFreq(swigCPtr, distance);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public virtual float coord(int overlap, int maxOverlap) {
    double ret = libCLcsharpPINVOKE.Similarity_coord(swigCPtr, overlap, maxOverlap);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

}

}
