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

📄 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-2000 by SMB GmbH. All rights reserved.//// $Id: DxArrayBag.java,v 1.11 2000/10/28 16:55:14 daniela Exp $package org.ozoneDB.DxLib;import java.util.*;import java.io.*;/** *  *  * @author <a href="http://www.softwarebuero.de/">SMB</a> * @version $Revision: 1.11 $Date: 2000/10/28 16:55:14 $ */public class DxArrayBag extends DxAbstractBag implements DxVector, DxVectorCollection {        final static long serialVersionUID = 1L;        private transient Vector vector;        private transient int itemCount;            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;    } }

⌨️ 快捷键说明

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