<commit_before>package com.io7m.jcanephora;

import javax.annotation.Nonnull;
import javax.annotation.concurrent.Immutable;

import com.io7m.jaux.Constraints;
import com.io7m.jaux.Constraints.ConstraintError;

/**
 * A immutable reference to an allocated array buffer.
 */

@Immutable public final class ArrayBuffer implements Buffer, GLResource
{
  private final int                            value;
  private final long                           elements;
  private final @Nonnull ArrayBufferDescriptor descriptor;

  ArrayBuffer(
    final int value,
    final long elements,
    final @Nonnull ArrayBufferDescriptor descriptor)
    throws ConstraintError
  {
    this.value =
      Constraints.constrainRange(
        value,
        0,
        Integer.MAX_VALUE,
        "Buffer ID value");
    this.elements =
      Constraints.constrainRange(
        elements,
        1,
        Integer.MAX_VALUE,
        "Buffer elements");
    this.descriptor =
      Constraints.constrainNotNull(descriptor, "Buffer descriptor");
  }

  /*
   * (non-Javadoc)
   * 
   * @see java.lang.Object#toString()
   */

  @Override public void delete(
    final @Nonnull GLInterface gl)
    throws ConstraintError,
      GLException
  {
    Constraints.constrainNotNull(gl, "OpenGL interface");
    gl.deleteArrayBuffer(this);
  }

  public @Nonnull ArrayBufferDescriptor getDescriptor()
  {
    return this.descriptor;
  }

  /**
   * Return the offset in bytes of the element at <code>index</code>.
   * 
   * @param index
   *          The index.
   * @throws ConstraintError
   *           Iff <code>0 <= index < this.getElements() == false</code>
   */

  public long getElementOffset(
    final int index)
    throws ConstraintError
  {
    return Constraints.constrainRange(index, 0, this.elements - 1)
      * this.getElementSizeBytes();
  }

  @Override public long getElements()
  {
    return this.elements;
  }

  @Override public long getElementSizeBytes()
  {
    return this.descriptor.getSize();
  }

  @Override public int getLocation()
  {
    return this.value;
  }

  @Override public long getSizeBytes()<commit_msg>Update javadoc<commit_after>package com.io7m.jcanephora;

import javax.annotation.Nonnull;
import javax.annotation.concurrent.Immutable;

import com.io7m.jaux.Constraints;
import com.io7m.jaux.Constraints.ConstraintError;

/**
 * A immutable reference to an allocated array buffer.
 */

@Immutable public final class ArrayBuffer implements Buffer, GLResource
{
  private final int                            value;
  private final long                           elements;
  private final @Nonnull ArrayBufferDescriptor descriptor;

  ArrayBuffer(
    final int value,
    final long elements,
    final @Nonnull ArrayBufferDescriptor descriptor)
    throws ConstraintError
  {
    this.value =
      Constraints.constrainRange(
        value,
        0,
        Integer.MAX_VALUE,
        "Buffer ID value");
    this.elements =
      Constraints.constrainRange(
        elements,
        1,
        Integer.MAX_VALUE,
        "Buffer elements");
    this.descriptor =
      Constraints.constrainNotNull(descriptor, "Buffer descriptor");
  }

  /*
   * (non-Javadoc)
   * 
   * @see java.lang.Object#toString()
   */

  @Override public void delete(
    final @Nonnull GLInterface gl)
    throws ConstraintError,
      GLException
  {
    Constraints.constrainNotNull(gl, "OpenGL interface");
    gl.deleteArrayBuffer(this);
  }

  public @Nonnull ArrayBufferDescriptor getDescriptor()
  {
    return this.descriptor;
  }

  /**
   * Return the offset in bytes of the element at <code>index</code>.
   * 
   * @param index
   *          The index.
   * @throws ConstraintError
   *           Iff <code>0 <= index < this.getElements() == false</code>
   */

  public long getElementOffset(
    final int index)
    throws ConstraintError
  {
    return Constraints.constrainRange(index, 0, this.elements - 1)
      * this.getElementSizeBytes();
  }

  /**
   * Retrieve the number of elements allocated in the buffer.
   */

  @Override public long getElements()
  {
    return this.elements;
  }

  /**
   * Retrieve the size in bytes of a single element in the buffer.
   */

  @Override public long getElementSizeBytes()
  {
    return this.descriptor.getSize();
  }

  /**
   * Return the raw OpenGL 'location' of the buffer.
   */

  @Override public int getLocation()
  {
    return this.value;
  }

  /**
   * Return the total size in bytes of the allocated buffer.
   */

  @Override public long getSizeBytes()
{'fraction_non_alphanumeric': 0.09167033935654473, 'fraction_numerical': 0.0035257822829440283, 'mean_word_length': 2.5938242280285038, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1873416', 'n_tokens_mistral': 1327, 'n_tokens_neox': 1272, 'n_words': 343}