org.openide.util.WeakSet.size()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(165)

本文整理了Java中org.openide.util.WeakSet.size()方法的一些代码示例,展示了WeakSet.size()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WeakSet.size()方法的具体详情如下:
包路径:org.openide.util.WeakSet
类名称:WeakSet
方法名:size

WeakSet.size介绍

[英]Number of items.
[中]物品数量。

代码示例

代码示例来源:origin: org.netbeans.api/org-openide-util

@Override
public Object clone() {      
  try {
    WeakSet<E> nws = (WeakSet<E>) super.clone();
    // sharing load factor is ok
    // but we can not share maps, recreate them
    nws.m = new SharedKeyWeakHashMap<E, Boolean>(size(), loadFactor);
    nws.s = nws.m.keySet();
    nws.addAll(this);
    return nws;
  } catch (CloneNotSupportedException e) {
    throw new IllegalStateException("base class doesn't support clone", e); // NOI18N
  }
}

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

/** Returns true if this set contains no elements.
*/
public boolean isEmpty() {
  return ((nullCount == 0) &&
      (size() == 0));
}
/** Returns an iterator over the elements in this set. */

代码示例来源:origin: in.jlibs/org-openide-util

/** Returns true if this set contains no elements.
*/
public boolean isEmpty() {
  return ((nullCount == 0) && (size() == 0));
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

/** Returns true if this set contains no elements.
*/
public boolean isEmpty() {
  return ((nullCount == 0) &&
      (size() == 0));
}
/** Returns an iterator over the elements in this set. */

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-vmd-model

private void fireActiveComponentsChanged (Collection<DesignComponent> activeComponents) {
  this.activeComponents = activeComponents;
  Listener[] Listeners;
  synchronized (listeners) {
    Listeners = listeners.toArray (new Listener[listeners.size ()]);
  }
  for (Listener listener : Listeners) {
    if (listener != null)
      listener.activeComponentsChanged (activeComponents);
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-modelimpl

public final void dispose() {
    for (int i = 0; i < instances.length; i++) {
      if (instances[i].size() > 0) {
        if (CndTraceFlags.TRACE_SLICE_DISTIBUTIONS) {
          Object[] arr = instances[i].toArray();
          System.out.println("Key cache " + instances[i].size()); // NOI18N
          Map<Class, Integer> classes = new HashMap<>();
          for (Object o : arr) {
            if (o != null) {
              Integer num = classes.get(o.getClass());
              if (num != null) {
                num = new Integer(num.intValue() + 1);
              } else {
                num = new Integer(1);
              }
              classes.put(o.getClass(), num);
            }
          }
          for (Map.Entry<Class, Integer> e : classes.entrySet()) {
            System.out.println("   " + e.getValue() + " of " + e.getKey().getName()); // NOI18N
          }
        }
        instances[i].clear();
        instances[i].resize(initialCapacity);
      }
    }
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-apt

@Override
  public final void dispose() {
    if (CndTraceFlags.TRACE_SLICE_DISTIBUTIONS) {
      Object[] arr = storage.toArray();
      System.out.println("Dispose macro cache "+arr.length + " " + getClass().getName()); // NOI18N
      Map<Class<?>, Integer> classes = new HashMap<Class<?>,Integer>();
      for(Object o : arr){
        if (o != null) {
          Integer i = classes.get(o.getClass());
          if (i != null) {
            i = Integer.valueOf(i.intValue() + 1);
          } else {
            i = Integer.valueOf(1);
          }
          classes.put(o.getClass(), i);
        }
      }
      for(Map.Entry<Class<?>,Integer> e:classes.entrySet()){
        System.out.println("   "+e.getValue()+" of "+e.getKey().getName()); // NOI18N
      }
    }
    if (storage.size() > 0) {
      storage.clear();
      storage.resize(initialCapacity);
    }
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-apt

@Override
  public final void dispose() {
    if (CndTraceFlags.TRACE_SLICE_DISTIBUTIONS) {
      Object[] arr = storage.toArray();
      System.out.println("Dispose macro cache "+arr.length + " " + getClass().getName()); // NOI18N
      Map<Class<?>, Integer> classes = new HashMap<Class<?>,Integer>();
      for(Object o : arr){
        if (o != null) {
          Integer i = classes.get(o.getClass());
          if (i != null) {
            i = Integer.valueOf(i.intValue() + 1);
          } else {
            i = Integer.valueOf(1);
          }
          classes.put(o.getClass(), i);
        }
      }
      for(Map.Entry<Class<?>,Integer> e:classes.entrySet()){
        System.out.println("   "+e.getValue()+" of "+e.getKey().getName()); // NOI18N
      }
    }
    if (storage.size() > 0) {
      storage.clear();
      storage.resize(initialCapacity);
    }
  }
}

代码示例来源:origin: uk.gov.nationalarchives.thirdparty.netbeans/org-openide-util

@Override
public Object clone() {      
  try {
    WeakSet<E> nws = (WeakSet<E>) super.clone();
    // sharing load factor is ok
    // but we can not share maps, recreate them
    nws.m = new SharedKeyWeakHashMap<E, Boolean>(size(), loadFactor);
    nws.s = nws.m.keySet();
    nws.addAll(this);
    return nws;
  } catch (CloneNotSupportedException e) {
    throw new IllegalStateException("base class doesn't support clone", e); // NOI18N
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-utils

@Override
  public final void dispose() {
    if (CndTraceFlags.TRACE_SLICE_DISTIBUTIONS){
      Object[] arr;
      synchronized (lock) {
        arr = storage.toArray();
      }
      System.out.println("Dispose cache "+name+" "+arr.length + " " + getClass().getName()); // NOI18N
      Map<Class, Integer> classes = new HashMap<Class,Integer>();
      for(Object o : arr){
        if (o != null) {
          Integer i = classes.get(o.getClass());
          if (i != null) {
            i = Integer.valueOf(i.intValue() + 1);
          } else {
            i = Integer.valueOf(1);
          }
          classes.put(o.getClass(), i);
        }
      }
      for(Map.Entry<Class,Integer> e:classes.entrySet()){
        System.out.println("   "+e.getValue()+" of "+e.getKey().getName()); // NOI18N
      }
    }
    if (storage.size() > 0) {
      storage.clear();
      storage.resize(initialCapacity);
    }
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-modelimpl

private void dispose() {
  for (int i = 0; i < instances.length; i++) {
    if (instances[i].size() > 0) {
      if (CndTraceFlags.TRACE_SLICE_DISTIBUTIONS) {
        Object[] arr = instances[i].toArray();
        System.out.println("Dispose UID cache " + instances[i].size()); // NOI18N
        Map<Class, Integer> uidClasses = new HashMap<>();
        Map<Class, Integer> keyClasses = new HashMap<>();
        for (Object o : arr) {
          if (o != null) {
            incCounter( uidClasses, o);
            if (o instanceof KeyBasedUID<?>) {
              Key k = ((KeyBasedUID<?>)o).getKey();
              incCounter( keyClasses, k);
            }
          }
        }
        for (Map.Entry<Class, Integer> e : uidClasses.entrySet()) {
          System.out.println("   " + e.getValue() + " of " + e.getKey().getName()); // NOI18N
        }
        System.out.println("-----------"); // NOI18N
        for (Map.Entry<Class, Integer> e : keyClasses.entrySet()) {
          System.out.println("   " + e.getValue() + " of " + e.getKey().getName()); // NOI18N
        }
      }
      instances[i].clear();
      instances[i].resize(initialCapacity);
    }
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-modelimpl

private void clearCache(int projectIndex) {
  for (int i = 0; i < instances.length; i++) {
    if (instances[i].size() > 0) {
      Object[] arr = instances[i].toArray();
      for (Object o : arr) {
        if (o instanceof CachedUID<?>) {
          CachedUID<?> cached = (CachedUID<?>) o;
          if (o instanceof KeyBasedUID<?>) {
            Key k = ((KeyBasedUID<?>)o).getKey();
            if (projectIndex == KeyUtilities.getProjectIndex(k)) {
              cached.clear();
            }
          }
        }
      }
    }
  }
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-vmd-io

private void fireActiveViewChanged (DataEditorView deactivatedView, DataEditorView activatedView) {
  Listener[] activeViewListeners;
  synchronized (listeners) {
    activeViewListeners = listeners.toArray (new Listener[listeners.size ()]);
  }
  for (Listener listener : activeViewListeners) {
    if (listener != null)
      listener.activeViewChanged (deactivatedView, activatedView);
  }
  DataObjectContext newContext = activatedView != null ? activatedView.getContext () : null;
  if (context != newContext) {
    if (context != null)
      context.removeDesignDocumentAwareness (awereness);
    context = newContext;
    if (context != null)
      context.addDesignDocumentAwareness (awereness);
    else
      awereness.setDesignDocument (null);
  }
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-vmd-model

private void fireActiveDocumentChanged (DesignDocument deactivatedDocument, final DesignDocument activatedDocument) {
  Listener[] Listeners;
  synchronized (listeners) {
    Listeners = listeners.toArray (new Listener[listeners.size ()]);
  }
  for (Listener listener : Listeners) {
    if (listener != null)
      listener.activeDocumentChanged (deactivatedDocument, activatedDocument);
  }
  if (deactivatedDocument != activatedDocument) {
    if (deactivatedDocument != null) {
      if (selectionListener == null)
        Debug.warning ("SelectionListener does not exist but it should"); // NOI18N
      else
        deactivatedDocument.getListenerManager ().removeDesignListener (selectionListener);
    }
    if (activatedDocument != null) {
      activatedDocument.getTransactionManager ().readAccess (new Runnable () {
        public void run () {
          activatedDocument.getListenerManager ().addDesignListener (selectionListener = new SelectionDesignListener (activatedDocument), FILTER_SELECTION);
          fireActiveComponentsChanged (activatedDocument.getSelectedComponents ());
        }
      });
    } else {
      fireActiveComponentsChanged (Collections.<DesignComponent>emptyList ());
    }
  }
}

相关文章