# Interface MocBuilder

All Known Implementing Classes:
  `BagMocBuilder, CdsMocBuilder`

public interface MocBuilder
Defines an object capable of storing HEALPix tiles and producing an ordered stream of spatial MOC UNIQ values. Since a UNIQ value has a 1:1 mapping with a HEALPix tile, the work required is to consolidate tiles within and between levels and provide the result as an ordered sequence.

You make multiple calls to `addTile(int, long)`, then a call to `endTiles()`, then the MOC is ready to interrogate.

In general instances of this interface are not expected to be thread-safe.

Since:
  28 Jan 2025
Author:
  Mark Taylor

## Method Summary

Modifier and Type
Method
Description
`void`
`addTile(int order, long ipix)`
Add a numbered tile at a given order.
`PrimitiveIterator.OfLong`
`createOrderedUniqIterator()`
Returns an iterator over the UNIQ values represented by this MOC in sequence.
`void`
`endTiles()`
Signal that no further tiles will be added.
`long[]`
`getOrderCounts()`
Returns an array of the number of tiles present at each order of the normalised MOC.

## Method Details

### addTile

void addTile(int order, long ipix)
Add a numbered tile at a given order. Adding a tile that has already been added has no effect.

Parameters:
  `order` - HEALPix order, in the range 0..29
  `ipix` - tile index within the given order, in the range 0..12*4^order

### endTiles

void endTiles()
Signal that no further tiles will be added.

### getOrderCounts

long[] getOrderCounts()
Returns an array of the number of tiles present at each order of the normalised MOC. The length of the array gives the number of orders present (the last element may not be zero, unless only one element is returned). The sum of the elements of this array gives the number of values that will be returned by `createOrderedUniqIterator()`.

Should only be called after `endTiles()` has been called.

### createOrderedUniqIterator

PrimitiveIterator.OfLong createOrderedUniqIterator()
Returns an iterator over the UNIQ values represented by this MOC in sequence. That means that the lower-order ones come first.

Should only be called after `endTiles()` has been called.