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

📄 street.java

📁 High performance DB query
💻 JAVA
字号:
/* * @(#)$Id: Street.java,v 1.7 2004/07/02 23:59:20 huebsch Exp $ * * Copyright (c) 2001-2004 Regents of the University of California. * All rights reserved. * * This file is distributed under the terms in the attached BERKELEY-LICENSE * file. If you do not find these files, copies can be found by writing to: * Computer Science Division, Database Group, Universite of California, * 617 Soda Hall #1776, Berkeley, CA 94720-1776. Attention: Berkeley License * * Copyright (c) 2003-2004 Intel Corporation. All rights reserved. * * This file is distributed under the terms in the attached INTEL-LICENSE file. * If you do not find these files, copies can be found by writing to: * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, * Berkeley, CA, 94704.  Attention:  Intel License Inquiry. */package overlay.location.can;import java.net.InetSocketAddress;import java.util.ArrayList;import java.util.Iterator;import services.network.Payload;import util.network.serialization.GenericByteBuffer;import util.network.serialization.SerializationManager;import util.network.serialization.SerializeList;/** * The class encapsulates a CAN street.  The street object contains a list of * neighbors.  The neighboors are unordered. */public class Street implements Payload {    public static long serialVersionUID =        SerializationManager.getSerialUID("overlay.location.can.Street");    private ArrayList myNeighbors;    /**     * DeSerialize the object from the provided GenericByteBuffer.     *     * @param inputBuffer     */    public Street(GenericByteBuffer inputBuffer) {        this.myNeighbors = SerializeList.deSerializeArrayList(inputBuffer);    }    /**     * Serialize the object into the provided GenericByteBuffer.     *     * @param outputBuffer     * @return     */    public long serialize(GenericByteBuffer outputBuffer) {        SerializeList.serialize(outputBuffer, myNeighbors);        return serialVersionUID;    }    /**     * Constructor Street     */    public Street() {        myNeighbors = new ArrayList();    }    /**     * Create a single-neighbor street.     *     * @param neighbor     */    public Street(InetSocketAddress neighbor) {        myNeighbors = new ArrayList();        myNeighbors.add(neighbor);    }    /**     * Create a street using the given array as its list of neighbors.     *     * @param neighbors     */    public Street(ArrayList neighbors) {        this.myNeighbors = neighbors;    }    /**     * Create a street which is a deep copy of the given Street.     *     * @param street     */    public Street(Street street) {        this.myNeighbors = (ArrayList) street.myNeighbors.clone();    }    /**     * Method isEmpty     * @return     */    public boolean isEmpty() {        return myNeighbors.isEmpty();    }    /**     * Get the street size in bytes.     * @return     */    public int getSize() {        return myNeighbors.size() * Payload.INET_SOCKET_SIZE;    }    /**     * Remove a node from the street     *     * @param node     */    public void remove(InetSocketAddress node) {        int index = myNeighbors.indexOf(node);        if (index != -1) {            myNeighbors.remove(index);        }    }    /**     * Insert a node at the end of the street     *     * @param node     */    public void insert(InetSocketAddress node) {        myNeighbors.add(node);    }    /**     * Get the length of the street in number of neighbors     * @return     */    public int getLength() {        return myNeighbors.size();    }    /**     * Return an iterator on for all the neighbors.     * @return     */    public Iterator iterator() {        return myNeighbors.iterator();    }}

⌨️ 快捷键说明

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