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


Java Occurred.BEFORE属性代码示例

本文整理汇总了Java中org.sdnplatform.sync.IVersion.Occurred.BEFORE属性的典型用法代码示例。如果您正苦于以下问题:Java Occurred.BEFORE属性的具体用法?Java Occurred.BEFORE怎么用?Java Occurred.BEFORE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.sdnplatform.sync.IVersion.Occurred的用法示例。


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

示例1: compare

public int compare(Versioned<S> v1, Versioned<S> v2) {
    Occurred occurred = v1.getVersion().compare(v2.getVersion());
    if(occurred == Occurred.BEFORE)
        return -1;
    else if(occurred == Occurred.AFTER)
        return 1;
    else
        return 0;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:9,代码来源:Versioned.java

示例2: doput

public boolean doput(K key, Versioned<V> value) throws SyncException {
    StoreUtils.assertValidKey(key);

    IVersion version = value.getVersion();

    while(true) {
        List<Versioned<V>> items = map.get(key);
        // If we have no value, optimistically try to add one
        if(items == null) {
            items = new ArrayList<Versioned<V>>();
            items.add(new Versioned<V>(value.getValue(), version));
            if (map.putIfAbsent(key, items) != null)
                continue;
            return true;
        } else {
            synchronized(items) {
                // if this check fails, items has been removed from the map
                // by delete, so we try again.
                if(map.get(key) != items)
                    continue;

                // Check for existing versions - remember which items to
                // remove in case of success
                List<Versioned<V>> itemsToRemove = new ArrayList<Versioned<V>>(items.size());
                for(Versioned<V> versioned: items) {
                    Occurred occurred = value.getVersion().compare(versioned.getVersion());
                    if(occurred == Occurred.BEFORE) {
                        return false;
                    } else if(occurred == Occurred.AFTER) {
                        itemsToRemove.add(versioned);
                    }
                }
                items.removeAll(itemsToRemove);
                items.add(value);
            }
            return true;
        }
    }
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:39,代码来源:InMemoryStorageEngine.java


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