
namespace clucene.net 
{

	using System;

	internal class _CL_p_p_lucene__search__SearchableArray : IDisposable 
	{
		private IntPtr swigCPtr;
		protected bool swigCMemOwn;

		internal _CL_p_p_lucene__search__SearchableArray(IntPtr cPtr, bool cMemoryOwn) 
		{
			swigCMemOwn = cMemoryOwn;
			swigCPtr = cPtr;
		}

		internal static IntPtr getCPtr(_CL_p_p_lucene__search__SearchableArray obj) 
		{
			return (obj == null) ? IntPtr.Zero : obj.swigCPtr;
		}

		~_CL_p_p_lucene__search__SearchableArray() 
		{
			Dispose();
		}

		public virtual void Dispose() 
		{
			if(swigCPtr != IntPtr.Zero && swigCMemOwn) 
			{
				swigCMemOwn = false;
				libCLcsharpPINVOKE.delete__CL_p_p_lucene__search__SearchableArray(swigCPtr);
			}
			swigCPtr = IntPtr.Zero;
			GC.SuppressFinalize(this);
		}

		public int length() 
		{
			return libCLcsharpPINVOKE._CL_p_p_lucene__search__SearchableArray_length(swigCPtr);
		}

		public void init(int len) 
		{
			libCLcsharpPINVOKE._CL_p_p_lucene__search__SearchableArray_init(swigCPtr, len);
		}

		public Searchable get(int idx) 
		{
			IntPtr cPtr = libCLcsharpPINVOKE._CL_p_p_lucene__search__SearchableArray_get(swigCPtr, idx);
			return (cPtr == IntPtr.Zero) ? null : new Searchable(cPtr, false);
		}

		public void set(Searchable a, int i) 
		{
			libCLcsharpPINVOKE._CL_p_p_lucene__search__SearchableArray_set(swigCPtr, Searchable.getCPtr(a), i);
		}


		public _CL_p_p_lucene__search__SearchableArray(Searchable[] val) : this(libCLcsharpPINVOKE.new__CL_p_p_lucene__search__SearchableArray(), true) 
		{
			int size=val.Length;
			this.init(size);
			for ( int i=0;i<size;i++ )
				this.set(val[i],i);
		}

		public Searchable[] toArray()
		{
			int len = this.length();
			Searchable[] ret = new Searchable[len];
			for ( int i=0;i<len;i++ )
				ret[i]=get(i);
			return ret;
		}
	}

}
