本文整理匯總了Java中java.util.LinkedHashSet.remove方法的典型用法代碼示例。如果您正苦於以下問題:Java LinkedHashSet.remove方法的具體用法?Java LinkedHashSet.remove怎麽用?Java LinkedHashSet.remove使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.LinkedHashSet
的用法示例。
在下文中一共展示了LinkedHashSet.remove方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: filter
import java.util.LinkedHashSet; //導入方法依賴的package包/類
Set<String> filter(SortedSet<String> allWords, String wanted) {
if (wanted == null || wanted.isEmpty()) {
return allWords;
}
LinkedHashSet<String> filtered = new LinkedHashSet<>();
LinkedHashSet<String> addAfterEnd = new LinkedHashSet<>();
String wantedLowerCase = wanted.toLowerCase();
for (String word : allWords) {
String wordLowerCase = word.toLowerCase();
if (wordLowerCase.startsWith(wantedLowerCase)) {
filtered.add(word);
} else if (wordLowerCase.indexOf(wantedLowerCase) != -1) {
addAfterEnd.add(word);
}
}
filtered.addAll(addAfterEnd);
/* remove wanted itself */
filtered.remove(wanted);
return filtered;
}
示例2: unregisterThrower
import java.util.LinkedHashSet; //導入方法依賴的package包/類
public void unregisterThrower(Class<?> interfaceClass, IEventThrower<?> thrower, boolean keepSubscribers){
synchronized (EVENT_THROWERS) {
if(EVENT_THROWERS.containsKey(interfaceClass)){
LinkedHashSet<IEventThrower<?>> list = EVENT_THROWERS.get(interfaceClass);
if(keepSubscribers){
Queue<Object> toKeep = new ArrayDeque<>();
Iterator<?> subscribers = thrower.getSubscribers();
while(subscribers.hasNext()){
Object listener = subscribers.next();
toKeep.add(listener);
}
if(!QUEUED_LISTENERS.containsKey(interfaceClass)){
QUEUED_LISTENERS.put(interfaceClass, toKeep);
}
}else{
thrower.clearSubscribers();
}
list.remove(thrower);
if(list.isEmpty()){
EVENT_THROWERS.remove(interfaceClass);
}
}
}
}
示例3: addOrderIsRespected
import java.util.LinkedHashSet; //導入方法依賴的package包/類
@Theory
public void addOrderIsRespected(Path p1, Path p2, Path p3) {
String[] actual = new ClassPath()
.add(p1, p2, p3)
.toStream()
.map(Path::toString)
.toArray(String[]::new);
LinkedHashSet<String> ps = new LinkedHashSet<>(); // respects add order
ps.add(p1.toString());
ps.add(p2.toString());
ps.add(p3.toString());
ps.remove("");
String[] expected = ps.toArray(new String[0]);
assertArrayEquals(expected, actual);
}
示例4: main
import java.util.LinkedHashSet; //導入方法依賴的package包/類
public static void main(String[] args) {
//create object of LinkedHashSet
LinkedHashSet lhashSet = new LinkedHashSet();
//add elements to LinkedHashSet object
lhashSet.add(new Integer("1"));
lhashSet.add(new Integer("2"));
lhashSet.add(new Integer("3"));
System.out.println("LinkedHashSet before removal : " + lhashSet);
/*
To remove an element from Java LinkedHashSet object use,
boolean remove(Object o) method.
This method removes an element from LinkedHashSet if it is present and returns
true. Otherwise remove method returns false.
*/
boolean blnRemoved = lhashSet.remove(new Integer("2"));
System.out.println("Was 2 removed from LinkedHashSet ? " + blnRemoved);
System.out.println("LinkedHashSet after removal : " + lhashSet);
}
示例5: main
import java.util.LinkedHashSet; //導入方法依賴的package包/類
public static void main(String[] args) {
//create LinkedHashSet object
LinkedHashSet lhashSet = new LinkedHashSet();
/*
To get the size of LinkedHashSet use
int size() method of LinkedHashSet class. It returns the number of elements
stored in LinkedHashSet object.
*/
System.out.println("Size of LinkedHashSet : " + lhashSet.size());
//add elements to LinkedHashSet object
lhashSet.add(new Integer("1"));
lhashSet.add(new Integer("2"));
lhashSet.add(new Integer("3"));
System.out.println("Size of LinkedHashSet after addition : " + lhashSet.size());
//remove one element from LinkedHashSet using remove method
lhashSet.remove(new Integer("1"));
System.out.println("Size of LinkedHashSet after removal : " + lhashSet.size());
}
示例6: removeTransformer
import java.util.LinkedHashSet; //導入方法依賴的package包/類
@Override
public synchronized void removeTransformer(Bundle pBundle, ClassTransformer transformer) {
LinkedHashSet<ClassTransformer> set = registeredTransformers.get(pBundle);
if (set == null || !set.remove(transformer)) {
throw new IllegalStateException("Transformer " + transformer + " not registered");
}
if (set.isEmpty()) {
registeredTransformers.remove(pBundle);
}
}
示例7: saveType
import java.util.LinkedHashSet; //導入方法依賴的package包/類
/**
* Save type or remove unselected type in the preferences.
* @param setName set name to save/remove or null for the default set
* @param typeName type name to save/remove
* @param selected state of the selection
*/
public void saveType(String setName, String typeName, boolean selected) {
LinkedHashSet<String> typeList = Gate.getUserConfig().getSet(
AnnotationSetsView.class.getName() + ".types");
String prefix = (setName == null) ? "." : setName + ".";
if (selected) {
typeList.add(prefix+typeName);
} else {
typeList.remove(prefix+typeName);
}
Gate.getUserConfig().put(
AnnotationSetsView.class.getName()+".types", typeList);
}
示例8: removeBatchLoadableEntityKey
import java.util.LinkedHashSet; //導入方法依賴的package包/類
/**
* After evicting or deleting or loading an entity, we don't
* need to batch fetch it anymore, remove it from the queue
* if necessary
*/
public void removeBatchLoadableEntityKey(EntityKey key) {
if ( key.isBatchLoadable() ) {
LinkedHashSet<EntityKey> set = batchLoadableEntityKeys.get( key.getEntityName());
if (set != null) {
set.remove(key);
}
}
}
示例9: createCookbookSearchPath
import java.util.LinkedHashSet; //導入方法依賴的package包/類
protected LinkedHashSet<String> createCookbookSearchPath(String cookbookRelativePath,
Map<String, Map<String, CmsCISimple>> cloudServices,
String cloudName) {
String cookbookDir = config.getCircuitDir();
if (!cookbookRelativePath.equals("")) {
cookbookDir = config.getCircuitDir().replace("packer",
cookbookRelativePath);
}
cookbookDir += "/components/cookbooks";
String sharedDir = config.getCircuitDir().replace("packer", "shared/cookbooks");
LinkedHashSet<String> cookbookPaths = new LinkedHashSet<>();
if (cloudServices != null) {
for (String serviceName : cloudServices.keySet()) { // for each service
CmsCISimple serviceCi = cloudServices.get(serviceName).get(cloudName);
if (serviceCi != null) {
String serviceClassName = serviceCi.getCiClassName();
String serviceCookbookCircuit = getCookbookPath(serviceClassName);
if (!serviceCookbookCircuit.equals(cookbookRelativePath)) {
cookbookPaths.add(config.getCircuitDir().replace("packer", serviceCookbookCircuit)
+ "/components/cookbooks");
}
}
}
}
if (cookbookPaths.size() > 0) {
//Remove the current component's circuit from the cookbook_path so that we can add it after other circuits
//This is to make sure the current component's circuit is higher priority in search path
cookbookPaths.remove(cookbookDir);
}
cookbookPaths.add(cookbookDir);
cookbookPaths.add(sharedDir);
return cookbookPaths;
}
示例10: run
import java.util.LinkedHashSet; //導入方法依賴的package包/類
/**
* Used to clean up on subscription disposed
*/
@Override
public void run() throws Exception {
LinkedHashSet<ObservableEmitter> queue = emitters.get(component);
if (queue != null && emitter != null) {
queue.remove(emitter);
}
}
示例11: ackReceived
import java.util.LinkedHashSet; //導入方法依賴的package包/類
public void ackReceived(String serverAddress, PacketInfo step1PacketInfo) {
LinkedHashSet<PacketInfo> synPacketInfos = syns.get(serverAddress);
if (synPacketInfos != null) {
synPacketInfos.remove(step1PacketInfo);
}
}