package clucene;
public class _CL_p_p_lucene__search__SortFieldArray {
  private long swigCPtr;
  protected boolean swigCMemOwn;

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

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

  protected void finalize() {
    delete();
  }

  public void delete() {
    if(swigCPtr != 0 && swigCMemOwn) {
      swigCMemOwn = false;
      CLjavaJNI.delete__CL_p_p_lucene__search__SortFieldArray(swigCPtr);
    }
    swigCPtr = 0;
  }

  public _CL_p_p_lucene__search__SortFieldArray(SortField[] val) {
    this(CLjavaJNI.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;
	}

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

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

  public SortField get(int idx) {
    long cPtr = CLjavaJNI._CL_p_p_lucene__search__SortFieldArray_get(swigCPtr, idx);
    return (cPtr == 0) ? null : new SortField(cPtr, false);
  }

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

}
