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

📄 dxarraybag.java

📁 Java的面向对象数据库系统的源代码
💻 JAVA
字号:
// You can redistribute this software and/or modify it under the terms of// the Ozone Library License version 1 published by ozone-db.org.//// The original code and portions created by SMB are// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.//// $Id: DxArrayBag.java,v 1.12 2001/02/20 11:23:28 daniela Exp $package org.ozoneDB.DxLib;import java.util.*;import java.io.*;/** *  *  * @author <a href="http://www.softwarebuero.de/">SMB</a> * @version $Revision: 1.12 $Date: 2001/02/20 11:23:28 $ */public class DxArrayBag extends DxAbstractBag implements DxVector, DxVectorCollection {        final static long serialVersionUID = 1L;        private transient Vector vector;        private transient int itemCount = 0;            public DxArrayBag() {        this( 32 );    }            public DxArrayBag( int initSpace ) {        vector = new Vector( initSpace );        itemCount = 0;    }        public synchronized boolean addFront( Object obj ) {        insertAtIndex( obj, 0 );        return true;    }         public synchronized boolean addBack( Object obj ) {        insertAtIndex( obj, size() );        return true;    }             /**     * Sets the component at the specified index of this vector to be the     * specified object. The previous component at that position is returned.     * The index must be a value greater than or equal to 0. The size of the     * array will grow if the specified index is greater than the current size.     */    public synchronized Object addAtIndex( Object obj, int index ) {        if (index >= vector.size()) {            vector.setSize( index + 1 );        }        Object old = vector.elementAt( index );        vector.setElementAt( obj, index );        if (old == null) {            itemCount++;        }         return old;    }            public Object elementAtIndex( int index ) {        return vector.elementAt( index );    }             /**     * Sets the component at the specified index to be null. The previous     * component at that position is returned. The index must be a value     * greater than or equal to 0 and less than the current size.     */    public synchronized Object removeAtIndex( int index ) {        Object old = vector.elementAt( index );        vector.setElementAt( null, index );        if (old != null) {            itemCount--;        }        return old;    }    /**     * Inserts the specified object as a component at the specified index. Each     * component with an index greater or equal to the specified index is     * shifted upward to have an index one greater than the value it had     * previously. The index must be a value greater than or equal to 0 and less     * than or equal to the current size of the vector.     */    public synchronized void insertAtIndex( Object obj, int index ) {        if (index >= vector.size()) {            vector.setSize( index );        }        vector.insertElementAt( obj, index );        itemCount++;    }    /**     * Deletes the component at the specified index. Each component in this     * array with an index greater or equal to the specified index is shifted     * downward to have an index one smaller than the value it had previously.     * The index must be a value greater than or equal to 0 and less than the     * current size.     */    public synchronized Object deleteAtIndex( int index ) {        Object old = vector.elementAt( index );        if (old != null) {            itemCount--;        }         vector.removeElementAt( index );        return old;    }             public int space() {        return vector.capacity();    }             public DxIterator iterator() {        return new DxVectorIterator( this );    }             public int count() {        return itemCount;    }        public int size() {        return vector.size();    }            public boolean isEmpty() {        return vector.isEmpty();    }             public synchronized void clear() {        vector.removeAllElements();        itemCount = 0;    }         public Vector internalVector() {        return vector;    }    public void decCounter() {        itemCount--;    }}

⌨️ 快捷键说明

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