Package java.util

Examples of java.util.LinkedList


        int selectedRow = -1;

        panesPanel.removeAll();
        gridbag.invalidateLayout(panesPanel);

        LinkedList panes = getPanes();
        LinkedList layerList = new LinkedList();

        int bufferIndex = Integer.MAX_VALUE;

        int i = 0; // track layer index
        Iterator it = panes.iterator();
        while (it.hasNext()) {

            LayerPane pane = (LayerPane) it.next();

            if (pane == backgroundLayerSeparator) {
                gridbag.setConstraints(pane, c);
                panesPanel.add(backgroundLayerSeparator);
                bufferIndex = i++;
                continue;
            }

            Layer layer = pane.getLayer();
            layer.setAddAsBackground(i > bufferIndex);
            gridbag.setConstraints(pane, c);
            panesPanel.add(pane);
            layerList.add(layer);

            if (pane.isSelected()) {
                selectedRow = i;
            }
            i++;
        }

        addFillerToPanesPanel();

        scrollPane.revalidate();

        // Scroll up or down as necessary to keep selected row
        // viewable
        if (selectedRow >= 0) {
            int spheight = scrollPane.getHeight();
            JScrollBar sb = scrollPane.getVerticalScrollBar();
            int sv = sb.getValue();
            int paneheight = ((LayerPane) panes.get(selectedRow)).getHeight();
            int rowvalue = selectedRow * paneheight;
            // Don't reset scrollBar unless the selected row
            // is not in the viewable range
            if (!((rowvalue > sv) && (rowvalue < spheight + sv))) {
                sb.setValue(rowvalue);
            }
        }

        Object[] layerArray = layerList.toArray();
        int length = layerArray.length;
        Layer[] newLayers = new Layer[length];

        for (int j = 0; j < length; j++) {
            newLayers[j] = (Layer) layerArray[j];
View Full Code Here


            r.get(j, pl1);
            Geo ret = segmentsIntersectOrNear(s1, s2, pl0, pl1, near, check);

            if (ret != null) {
                if (list == null) {
                    list = new LinkedList();
                }

                list.add(ret);
                // ret is actually the last created check. This mechanism limits
                // the creation of Geos to only hits + 1.
View Full Code Here

                sl1 = s.get(i, sl1);
                Geo ret = segmentsIntersectOrNear(sl0, sl1, pl0, pl1, near);

                if (ret != null) {
                    if (list == null) {
                        list = new LinkedList();
                    }
                    list.add(ret);
                }
                sl0 = sl1;
            }
View Full Code Here

     *
     * @param primaryDir Primary Directory for this Collection
     */
    public CollectionStorage(String primaryDir) {
        this.primaryDir = primaryDir;
        extendedDirs = new LinkedList();
        currentDir = primaryDir;
    }
View Full Code Here

        // set latest dataPage PageNumber in bufferedPage
        PageNumber ldpReservedPage = new PageNumber(ByteTool.bytesToInt(metaData, BTreeSpec.LATEST_DATA_PAGE_LIST_OFF, bTree.getBTreeSpec().getMsbFirst()));
        ldpReservedPage.setTreeId(bTree.getBtreeId());

        LinkedList reservedList = new LinkedList();

        if (ldpReservedPage.getPageNumber() > 0) {
            // (page size - page number - next page number) / 4
            int pageTotalSpace = (bTree.getBTreeSpec().getPageSize() - BTreeSpec.PAGENUMBER_BYTE_SIZE - BTreeSpec.PAGENUMBER_BYTE_SIZE) / BTreeSpec.PAGENUMBER_BYTE_SIZE;
            int nextLDPReservedPageNum = ldpReservedPage.getPageNumber();
            byte[] page = bTree.getBuffer().getPage(bTree.getBtreeId(), ldpReservedPage);
            if (page != null) {
                int ldpNumOffset = BTreeSpec.OFF_PAGENUMBER + BTreeSpec.PAGENUMBER_BYTE_SIZE;
                int ldpNum = ByteTool.bytesToInt(page, ldpNumOffset, bTree.getBTreeSpec().getMsbFirst());
                while (nextLDPReservedPageNum > 0) {
                    for (int i = 0; i < ldpNum; i++) {
                        PageNumber latestDataPage = new PageNumber(ByteTool.bytesToInt(page, ldpNumOffset + 4 + i * BTreeSpec.PAGENUMBER_BYTE_SIZE, bTree.getBTreeSpec().getMsbFirst()));
                        latestDataPage.setTreeId(bTree.getBtreeId());
                        bTree.getBuffer().addToLatestDataPageListWhenOpenBTree(bTree.getBtreeId(), latestDataPage);
                    }
                    if ((ldpNum < pageTotalSpace - 1) || (ldpNum == pageTotalSpace)) {
                        nextLDPReservedPageNum = -1;
                    } else {
                        nextLDPReservedPageNum = ByteTool.bytesToInt(page, bTree.getBTreeSpec()
                                .getPageSize() - 4, bTree.getBTreeSpec().getMsbFirst());
                    }
                    /*              this page can't be used because if btree is closed abnormally in the way
                                    metapage contains old info whereas other pages has been updated. Thus maybe
                                    this "ldpReservedPage" is reused and occurs in some BTree(Data)Node's links. Then
                                    btree reopen we read obsolete data from meta page and put this "ldpReservedPage" to
                                    free page list, which later may cause to "Used Freed page" exception. The same
                                    thing happens to pages storing free pages. We prefer to losing these "savePages".
                    */
                    bTree.getBuffer().releasePage(bTree.getBtreeId(), ldpReservedPage, false);
                    reservedList.add(ldpReservedPage);
                    if (nextLDPReservedPageNum > 0) {
                        ldpReservedPage = new PageNumber(nextLDPReservedPageNum);
                        ldpReservedPage.setTreeId(bTree.getBtreeId());
                        page = bTree.getBuffer().getPage(bTree.getBtreeId(), ldpReservedPage);
                        if (page == null) {
                            break;
                        }
                        ldpNum = ByteTool.bytesToInt(page, ldpNumOffset, bTree.getBTreeSpec().getMsbFirst());
                    }
                }
            }
        }

        // set free list in buffererdPage

        int freePageNums = ByteTool.bytesToInt(metaData, BTreeSpec.FREE_PAGE_LIST_OFF, bTree.getBTreeSpec().getMsbFirst());
        if (freePageNums == 0) {
            bTree.getBuffer().setReserveredList(bTree.getBtreeId(), reservedList);
            return;
        }

        logger.debug("freePageNums = " + freePageNums);
        int leftSpace = (bTree.getBTreeSpec().getPageSize() - BTreeSpec.FREE_PAGE_LIST_OFF - 4) / BTreeSpec.PAGENUMBER_BYTE_SIZE;
        int size = (freePageNums <= leftSpace) ? freePageNums : (leftSpace - 1);

        for (int i = 0; i < size; i++) {
            PageNumber freePage = new PageNumber(ByteTool.bytesToInt(metaData, BTreeSpec.FREE_PAGE_LIST_OFF + 4 + i * BTreeSpec.PAGENUMBER_BYTE_SIZE, bTree.getBTreeSpec().getMsbFirst()));
            freePage.setTreeId(bTree.getBtreeId());
            bTree.getBuffer().addToFreeListWhenOpenBTree(bTree.getBtreeId(), freePage);
        }

        if (freePageNums > leftSpace) {
            //(page size - free page number - next page number)/ 4
            int pageTotalSpace = (bTree.getBTreeSpec().getPageSize() - 4 - BTreeSpec.PAGENUMBER_BYTE_SIZE) / BTreeSpec.PAGENUMBER_BYTE_SIZE;

            int nextFPReservedPageNum = ByteTool.bytesToInt(metaData, BTreeSpec.FREE_PAGE_LIST_OFF + 4 + size * BTreeSpec.PAGENUMBER_BYTE_SIZE, bTree.getBTreeSpec().getMsbFirst());
            PageNumber fpReservedPage = new PageNumber(nextFPReservedPageNum);
            fpReservedPage.setTreeId(bTree.getBtreeId());
            byte[] page = bTree.getBuffer().getPage(bTree.getBtreeId(), fpReservedPage);
            if (page != null) {
                int freePageNumOffset = BTreeSpec.OFF_PAGENUMBER + BTreeSpec.PAGENUMBER_BYTE_SIZE;
                int freeNum = ByteTool.bytesToInt(page, freePageNumOffset, bTree.getBTreeSpec().getMsbFirst());
                while (nextFPReservedPageNum > 0) {
                    for (int i = 0; i < freeNum; i++) {
                        PageNumber freePage = new PageNumber(ByteTool.bytesToInt(page, freePageNumOffset + 4 + i * BTreeSpec.PAGENUMBER_BYTE_SIZE, bTree.getBTreeSpec().getMsbFirst()));
                        freePage.setTreeId(bTree.getBtreeId());
                        bTree.getBuffer().addToFreeListWhenOpenBTree(bTree.getBtreeId(), freePage);
                    }
                    if ((freeNum < pageTotalSpace - 1) || (freeNum == pageTotalSpace)) {
                        nextFPReservedPageNum = -1;
                    } else {
                        nextFPReservedPageNum = ByteTool.bytesToInt(page, bTree.getBTreeSpec().getPageSize() - BTreeSpec.PAGENUMBER_BYTE_SIZE, bTree.getBTreeSpec().getMsbFirst());
                    }
                    /* add the page which save freelist to freelist,becuase it's unuseful later */
                    fpReservedPage.setTreeId(bTree.getBtreeId());
                    reservedList.add(fpReservedPage);
                    bTree.getBuffer().releasePage(bTree.getBtreeId(), fpReservedPage, false);
                    if (nextFPReservedPageNum > 0) {
                        fpReservedPage = new PageNumber(nextFPReservedPageNum);
                        fpReservedPage.setTreeId(bTree.getBtreeId());
                        page = bTree.getBuffer().getPage(bTree.getBtreeId(), fpReservedPage);
View Full Code Here

        dir = dir.substring(0, dir.lastIndexOf(File.separator));
        BTreeSpec indexSpec = getBuffer().getBTreeSpec(dir + File.separator + IMPLICITLY_OPEN_FILE, IDBIndex.BTREE, kContext);
        indexBTree = (BTree) indexSpec.btree;
        //for index tree, adopting locking the whole tree
        id2root = new Hashtable();
        cleanIdQueue = new LinkedList();
    }
View Full Code Here

     */
    public LogRecord pop() throws ChaiDBException {
        if (lastTxnList == null) {
            TransactionLog[] arrList = new TransactionLog[txnList.size()];
            arrList = (TransactionLog[]) txnList.values().toArray(arrList);
            lastTxnList = new LinkedList();
            for (int i = arrList.length - 1; i >= 0; i--) {
                lastTxnList.add(arrList[i]);
            }
        }
        while (lastTxnList.size() > 0) {
View Full Code Here

     * Given a Class, find all the objects in the MapHandler that are
     * assignment-compatible with that Class. A Collection is always returned,
     * although it may be empty.
     */
    public Collection getAll(Class someClass) {
        Collection collection = new LinkedList();

        if (someClass != null) {
            Iterator it = iterator();
            while (it.hasNext()) {
                Object someObj = it.next();
                if (someClass.isInstance(someObj)) {
                    collection.add(someObj);
                }
            }
        }

        return collection;
View Full Code Here

    public List getFields(String tag) {
        Object obj = fields.get(tag);
        if (obj instanceof List) {
            return (List) obj;
        } else {
            LinkedList ll = new LinkedList();
            ll.add(obj);
            return ll;
        }
    }
View Full Code Here

    /**
     * Return a java.util.List of ASRPDirectories known by this THF
     * file.
     */
    public List getASRPDirectories() {
        LinkedList asrpDirs = new LinkedList();
        List fields = getFields(TransmittalHeaderFile.DATA_SET_DESCRIPTION);
        for (Iterator it = fields.iterator(); it.hasNext();) {
            DDFField ddf = (DDFField) it.next();
            if (ddf.getFieldDefn().getName().equals("FDR")) {
                List datasets = ddf.getSubfields("NAM");

                for (Iterator it2 = datasets.iterator(); it2.hasNext();) {
                    DDFSubfield ddfs = (DDFSubfield) it2.next();
                    String asrpdString = rootDir + "ASRP/" + ddfs.stringValue();
                    if (Debug.debugging("asrp")) {
                        Debug.output("TransmittalHeaderFile creating "
                                + asrpdString + " from " + rootDir + TRANS);
                    }
                    asrpDirs.add(new ASRPDirectory(asrpdString));
                }
            }
        }

        return asrpDirs;
View Full Code Here

TOP

Related Classes of java.util.LinkedList

Copyright © 2015 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.