⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 byte_arraywraper.java

📁 j2me解压缩j2me解压缩j2me解压缩j2me解压缩j2me解压缩j2me解压缩j2me解压缩j2me解压缩
💻 JAVA
字号:
//-*-java-*-/*Copyright (c) 2003 Asoft ltd. All rights reserved.Redistribution and use in source and binary forms, with or withoutmodification, are permitted provided that the following conditions are met:1. Redistributions of source code must retain the above copyright notice,this list of conditions and the following disclaimer.2. Redistributions in binary form must reproduce the above copyrightnotice, this list of conditions and the following disclaimer inthe documentation and/or other materials provided with the distribution.3. The names of the authors may not be used to endorse or promote productsderived from this software without specific prior written permission.THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY ANDFITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ASOFTLTD. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOTLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OFLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDINGNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *//*                                                                              *Copyright (c) 2003 Asoft ltd. All rights reserved.                             *www.asoft.ru                                                                   *Authors: Alexandre Rusev, Alexey Soloviev                                      */package com.asoft.midp.dynarray;import java.util.Vector;/**���� ����� ������������ ��� ����, ����� ������������ ������ � �������� ������� * ����� ��������� byte_AccessibleArray. *<p>��� ������ ����� ���� �����, ���� ���� ���������� ����������������� *���������� �� ���������� ������, ������� ����� �� ������� ����� *����� ���������� J2ME �� ����� �������� �� ��� ����� ������. */public final class byte_arraywraper implements byte_AccessibleArray{    private static final boolean FAST = true;    private final byte[] array;    private final int offs;    private final int length;    public byte_arraywraper(byte[] array)    {        this(array, 0, array.length);    }    public byte_arraywraper(byte[] array, int offs, int length)    {        this.array = array;        this.offs = offs;        this.length = length;    }    public int length()    {        return length;    }    public final int totalAllocated()    {        return array.length;    }    public int blockSize()    {        return array.length;    }    public final void set(int n, byte val)    {        array[offs + n] = val;    }    public final byte get(int n)    {        return array[offs + n];    }    public final void copyFrom(byte[] src, int srcoff, int dstoff, int len)    {        System.arraycopy(src, srcoff, array, offs + dstoff, len);    }    public void copyTo(int srcoff, byte[] dst, int dstoff, int len)    {        System.arraycopy(array, offs + srcoff, dst, dstoff, len);    }    public final void copyTo(int srcoff, byte_AccessibleArray dst, int dstoff, int len)    {        dst.copyFrom(array, offs + srcoff, dstoff, len);    }    public final void copyFrom(byte_AccessibleArray src, int srcoff, int dstoff, int len)    {        src.copyTo(srcoff, this, dstoff, len);    }    public final void clear(int off, int len)    {        if (FAST)        {            //FAST==true            byte[] bb = new byte[Math.min(50, length())];            final int c = length() / bb.length;            for (int i = 0; i <= c; ++i)            {                final int off1 = off + c * bb.length;                if (off1 < length())                {                    System.arraycopy(bb, 0, array, offs + off1, Math.min(bb.length, length() - off1));                }            }//for        }        else        {            //FAST==false            for (int i = off; i < off + len; ++i)            {                array[offs + i] = (byte) 0;            }//for        }//if(FAST)    }    public static void Copy(byte_AccessibleArray src, int srcoff, byte_AccessibleArray dst, int dstoff, int len)    {        if (len == 0)        {            return;        }        src.copyTo(srcoff, dst, dstoff, len);    }    public static void Copy(byte[] src, int srcoff, byte_AccessibleArray dst, int dstoff, int len)    {        dst.copyFrom(src, srcoff, dstoff, len);    }    public static final void Copy(byte_AccessibleArray src, int srcoff, byte[] dst, int dstoff, int len)    {        src.copyTo(srcoff, dst, dstoff, len);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -