
namespace clucene.net {

using System;

	public class _CL_p_p_lucene__search__SortFieldArray : IDisposable 
	{
		private IntPtr swigCPtr;
		protected bool swigCMemOwn;

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

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

		~_CL_p_p_lucene__search__SortFieldArray() 
		{
			Dispose();
		}

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

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

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

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

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

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

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

}
