// Copyright 2017-2018 - Universite de Strasbourg/CNRS
// The CDS HEALPix library is developped by the Centre de Donnees
// astronomiques de Strasbourgs (CDS) from the following external papers:
//  - [Gorsky2005]     - "HEALPix: A Framework for High-Resolution Discretization and
//                       Fast Analysis of Data Distributed on the Sphere"
//                       http://adsabs.harvard.edu/abs/2005ApJ...622..759G
//  - [Calabretta2004] - "Mapping on the HEALPix grid"
//                       http://adsabs.harvard.edu/abs/2004astro.ph.12607C
//  - [Calabretta2007] - "Mapping on the HEALPix grid"
//                       http://adsabs.harvard.edu/abs/2007MNRAS.381..865C
//  - [Reinecke2015]   - "Efficient data structures for masks on 2D grids"
//                       http://adsabs.harvard.edu/abs/2015A&A...580A.132R
// It is distributed under the terms of the BSD License 2.0
//
// This file is part of the CDS HEALPix library.
//

package cds.healpix;


final class ArraysListOfLong {

  long[] a;
  private int i = 0;
  
  public ArraysListOfLong(int initCapacity) {
    this.a = new long[Math.max(initCapacity, 3)];
  }
  
  public void add(long l) {
    if (this.i == this.a.length) {
      long[] newa = new long[(int) (a.length * 1.35)];
      System.arraycopy(this.a, 0, newa, 0, a.length);
      this.a = newa;
    }
    this.a[this.i++] = l;
  }
  
  public long get(int i) {
    if (i < 0 || this.size() <= i) {
      throw new IndexOutOfBoundsException(); 
    }
    return this.a[i];
  }
  
  public int size() {
    return this.i;
  }
  
}
