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

📄 dxbbtree.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: DxBBTree.java,v 1.6 2000/10/28 16:55:14 daniela Exp $package org.ozoneDB.DxLib;import java.io.*;/** * Non-public class that represents a key->value map implemented * using a BBTree. This is used for DxTreeMap and DxTreeSet implementations. */final class DxBBTree {        final static long serialVersionUID = 1L;        //balance faktor fuer den baum (0.25..0.32); je kleiner, desto    //schiefer ist evtl. der baum und umso weniger muss auch rotiert werden    final static int BB_ALPHA = 26;    final static int BB_BALANCE = 50;    final static int BB_MAX = 100;        DxBBnode quietRoot;    int itemCount = 0;    DxComparator comparator = null;            /**     */    public DxBBTree() {        comparator = new DxStandardComparator();        quietRoot = new DxBBnode( null, null, comparator );    }            /**     */    public DxBBTree( DxComparator _comparator ) {        comparator = _comparator;        quietRoot = new DxBBnode( null, null, comparator );    }            /**     */    public synchronized boolean addForKey( Object obj, Object key ) {        DxBBnode node = new DxBBnode( obj, key, comparator );        if (itemCount == 0) {            node.isRight = true;            node.pa = quietRoot;            quietRoot.re = node;            itemCount++;            return true;        }         if (root().insertNode( node )) {            itemCount++;            return true;        } else {            return false;        }     }             /**     */    public Object elementForKey( Object key ) {        if (root() == null) {            return null;        }                 DxBBnode node = root().findNodeKey( key );        if (node != null) {            return node.data;        }                 return null;    }             /**     */    public Object keyForElement( Object obj ) {        if (root() == null) {            return null;        }                 DxBBnode node = root().findNodeObject( obj );        if (node != null) {            return node.key;        }                 return null;    }             /**     */    public synchronized Object removeForKey( Object key ) {        if (root() == null) {            return null;        }                 DxBBnode node = root().removeNodeKey( key );        if (node != null) {            itemCount--;            return node.data;        } else {            return null;        }     }             /**     */    public int count() {        return itemCount;    }             /**     */    public boolean isEmpty() {        return itemCount == 0;    }             /**     */    public boolean containsKey( Object key ) {        return elementForKey( key ) != null;    }             /**     */    DxBBnode root() {        return quietRoot.re;    } }

⌨️ 快捷键说明

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