当前位置: 首页>>代码示例>>Java>>正文


Java TLinkable.getNext方法代码示例

本文整理汇总了Java中gnu.trove.list.TLinkable.getNext方法的典型用法代码示例。如果您正苦于以下问题:Java TLinkable.getNext方法的具体用法?Java TLinkable.getNext怎么用?Java TLinkable.getNext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gnu.trove.list.TLinkable的用法示例。


在下文中一共展示了TLinkable.getNext方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: remove

import gnu.trove.list.TLinkable; //导入方法依赖的package包/类
/**
 * Removes the specified element from the list.  Note that
 * it is the caller's responsibility to ensure that the
 * element does, in fact, belong to this list and not another
 * instance of TLinkedList.
 *
 * @param o a TLinkable element already inserted in this list.
 * @return true if the element was a TLinkable and removed
 */
@SuppressWarnings({"unchecked"})
public boolean remove( Object o ) {
    if ( o instanceof TLinkable ) {
        T p, n;
        TLinkable<T> link = (TLinkable<T>) o;

        p = link.getPrevious();
        n = link.getNext();

        if ( n == null && p == null ) { // emptying the list
            // It's possible this object is not something that's in the list. So,
            // make sure it's the head if it doesn't point to anything. This solves
            // problems caused by removing something multiple times.
            if ( o != _head ) {
                return false;
            }

            _head = _tail = null;
        } else if ( n == null ) { // this is the tail
            // make previous the new tail
            link.setPrevious( null );
            p.setNext( null );
            _tail = p;
        } else if ( p == null ) { // this is the head
            // make next the new head
            link.setNext( null );
            n.setPrevious( null );
            _head = n;
        } else {            // somewhere in the middle
            p.setNext( n );
            n.setPrevious( p );
            link.setNext( null );
            link.setPrevious( null );
        }

        _size--;            // reduce size of list
        return true;
    } else {
        return false;
    }
}
 
开发者ID:JianpingZeng,项目名称:xcc,代码行数:51,代码来源:TLinkedList.java

示例2: remove

import gnu.trove.list.TLinkable; //导入方法依赖的package包/类
/**
 * Removes the specified element from the list.  Note that
 * it is the caller's responsibility to ensure that the
 * element does, in fact, belong to this list and not another
 * instance of TLinkedList.
 *
 * @param o a TLinkable element already inserted in this list.
 * @return true if the element was a TLinkable and removed
 */
@Override
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
    if ( o instanceof TLinkable ) {
        T p, n;
        TLinkable<T> link = (TLinkable<T>) o;

        p = link.getPrevious();
        n = link.getNext();

        if ( n == null && p == null ) { // emptying the list
            // It's possible this object is not something that's in the list. So,
            // make sure it's the head if it doesn't point to anything. This solves
            // problems caused by removing something multiple times.
            if ( o != _head ) {
                return false;
            }

            _head = _tail = null;
        } else if ( n == null ) { // this is the tail
            // make previous the new tail
            link.setPrevious( null );
            p.setNext( null );
            _tail = p;
        } else if ( p == null ) { // this is the head
            // make next the new head
            link.setNext( null );
            n.setPrevious( null );
            _head = n;
        } else {            // somewhere in the middle
            p.setNext( n );
            n.setPrevious( p );
            link.setNext( null );
            link.setPrevious( null );
        }

        _size--;            // reduce size of list
        return true;
    } else {
        return false;
    }
}
 
开发者ID:palantir,项目名称:trove-3.0.3,代码行数:52,代码来源:TLinkedList.java


注:本文中的gnu.trove.list.TLinkable.getNext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。