All Downloads are FREE. Search and download functionalities are using the official Maven repository.

Alachisoft.NCache.Common.DataReader.TwoDimensionalArray Maven / Gradle / Ivy

package Alachisoft.NCache.Common.DataReader;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.lang.reflect.Array;

public class TwoDimensionalArray implements Cloneable, Serializable
{
    private int _sizeOfReference;
    public Object[][] _chunks;
    private int _length = 0;
    private boolean customLength = false;

    public TwoDimensionalArray(int length)
    {
        Initialize(length);
    }

    private void Initialize(int length)
    {
        _length = length;
        _chunks = new Object[length][1];

    }
    public void set(int index, Object value)
    {
        _chunks[index][0] = value;
    }
    public Object get(int index)
    {
        return _chunks[index][0];
    }


    public int size()
    {
        return _length;
    }

    public Object clone()
    {
        TwoDimensionalArray newarray = new TwoDimensionalArray(_length);
        System.arraycopy(this, 0, newarray, 0, _length);
        return newarray;
    }

    public byte[] toByteArray(){
        byte[] bytes = new byte[_length];
        for (int i = 0; i < _length; i++) {
                bytes[i] = (byte)(_chunks[i][0]);
            }
        return bytes;
    }
    public void copyFromByteArray(byte[] sourceArray){
        for (int i = 0; i < sourceArray.length; i++)
        {
            _chunks[i][0] = sourceArray[i];
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy