// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT   = 0;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT      = 0;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT      = 1;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT    = 3;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT     = 2;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT       = 2;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT      = 3;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final String LS = System.getProperty("line.separator");
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT     = 1;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static void assertBounds(final long reqOff, final long reqLen, final long allocSize) {
//   assert ((reqOff | reqLen | (reqOff + reqLen) | (allocSize - (reqOff + reqLen))) >= 0) :
//     "reqOffset: " + reqOff + ", reqLength: " + reqLen
//     + ", (reqOff + reqLen): " + (reqOff + reqLen) + ", allocSize: " + allocSize;
// }
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;


import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LS;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.assertBounds;
import static com.yahoo.memory4.UnsafeUtil.unsafe;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
/*
 * Copyright 2017, Yahoo! Inc. Licensed under the terms of the
 * Apache License 2.0. See LICENSE file at the project root for terms.
 */

package com.yahoo.memory4;



/**
 * @author Lee Rhodes
 */
public abstract class Memory {

  //BYTE BUFFER
  /**
   * Accesses the given ByteBuffer for read-only operations.
   * @param byteBuf the given ByteBuffer
   * @return the given ByteBuffer for read-only operations.
   */
  public static Memory wrap(final ByteBuffer byteBuf) {
    if (byteBuf.order() != ByteOrder.nativeOrder()) {
      throw new IllegalArgumentException(
          "Memory does not support " + (byteBuf.order().toString()));
    }
    final MemoryState state = new MemoryState();
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT   = 0;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT      = 0;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT      = 1;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT    = 3;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT     = 2;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT       = 2;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT      = 3;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final String LS = System.getProperty("line.separator");
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT     = 1;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static void assertBounds(final long reqOff, final long reqLen, final long allocSize) {
//   assert ((reqOff | reqLen | (reqOff + reqLen) | (allocSize - (reqOff + reqLen))) >= 0) :
//     "reqOffset: " + reqOff + ", reqLength: " + reqLen
//     + ", (reqOff + reqLen): " + (reqOff + reqLen) + ", allocSize: " + allocSize;
// }
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;


// Path: src/main/java/com/yahoo/memory4/Memory.java
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LS;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.assertBounds;
import static com.yahoo.memory4.UnsafeUtil.unsafe;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

/*
 * Copyright 2017, Yahoo! Inc. Licensed under the terms of the
 * Apache License 2.0. See LICENSE file at the project root for terms.
 */

package com.yahoo.memory4;



/**
 * @author Lee Rhodes
 */
public abstract class Memory {

  //BYTE BUFFER
  /**
   * Accesses the given ByteBuffer for read-only operations.
   * @param byteBuf the given ByteBuffer
   * @return the given ByteBuffer for read-only operations.
   */
  public static Memory wrap(final ByteBuffer byteBuf) {
    if (byteBuf.order() != ByteOrder.nativeOrder()) {
      throw new IllegalArgumentException(
          "Memory does not support " + (byteBuf.order().toString()));
    }
    final MemoryState state = new MemoryState();
    state.putByteBuffer(byteBuf);