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


Java ArrayList.clear方法代码示例

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


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

示例1: populateEntryEventList

import java.util.ArrayList; //导入方法依赖的package包/类
private void populateEntryEventList(DistributedMember target,
    ArrayList<ArrayList<DistTxThinEntryState>> entryEventList, TreeSet<String> sortedRegionMap) {
  DistTXCoordinatorInterface distTxItem = target2realDeals.get(target);
  sortedRegionMap.clear();
  distTxItem.gatherAffectedRegionsName(sortedRegionMap, false, true);

  // Get region as per sorted order of region path
  entryEventList.clear();
  for (String rName : sortedRegionMap) {
    ArrayList<DistTxThinEntryState> entryStates = this.txEntryEventMap.get(rName);
    if (entryStates == null) {
      throw new UnsupportedOperationInTransactionException(LocalizedStrings.DISTTX_TX_EXPECTED
          .toLocalizedString("entryStates for " + rName + " at target " + target, "null"));
    }
    entryEventList.add(entryStates);
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:18,代码来源:DistTXStateProxyImplOnCoordinator.java

示例2: Open

import java.util.ArrayList; //导入方法依赖的package包/类
public boolean Open(DataInputStream F){    //Lee la TSS del Flujo F.        
    ArrayList <String> Aux = new ArrayList<String>();
    
    try{            
            //Leer la Cant. de StringCtte's.            
        int n = F.readInt();
        
            //Leer los StringCtte's y depositarlas en la lista Aux.
        for (int i=1; i<=n; i++)
            Aux.add( F.readUTF() );
        
            //Copiar lista Aux a L y liberar Aux
        L.clear();      L=null;            
        L = Clonar(Aux);
        Aux.clear();    Aux = null;
        
        return true;                
    }
    catch(Exception e){
    }
    
    return false;
}
 
开发者ID:mariocordova,项目名称:codigo3,代码行数:24,代码来源:TSS.java

示例3: getViewsIntersectingRegion

import java.util.ArrayList; //导入方法依赖的package包/类
private void getViewsIntersectingRegion(int cellX, int cellY, int spanX, int spanY,
        View dragView, Rect boundingRect, ArrayList<View> intersectingViews) {
    if (boundingRect != null) {
        boundingRect.set(cellX, cellY, cellX + spanX, cellY + spanY);
    }
    intersectingViews.clear();
    Rect r0 = new Rect(cellX, cellY, cellX + spanX, cellY + spanY);
    Rect r1 = new Rect();
    final int count = mShortcutsAndWidgets.getChildCount();
    for (int i = 0; i < count; i++) {
        View child = mShortcutsAndWidgets.getChildAt(i);
        if (child == dragView) continue;
        LayoutParams lp = (LayoutParams) child.getLayoutParams();
        r1.set(lp.cellX, lp.cellY, lp.cellX + lp.cellHSpan, lp.cellY + lp.cellVSpan);
        if (Rect.intersects(r0, r1)) {
            mIntersectingViews.add(child);
            if (boundingRect != null) {
                boundingRect.union(r1);
            }
        }
    }
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:23,代码来源:CellLayout.java

示例4: isXPickTest

import java.util.ArrayList; //导入方法依赖的package包/类
@Test
public void isXPickTest()
{
    doReturn(true).when(itemMeta).hasLore();
    doReturn(true).when(tool).hasItemMeta();
    doReturn(itemMeta).when(tool).getItemMeta();
    //this is the wrong lore
    ArrayList<String> lore = new ArrayList<String>();
    lore.add(ChatColor.GREEN + "Pick o'Plenty");
    doReturn(lore).when(itemMeta).getLore();
    assertFalse(Pickoplenty.isPick(tool));
 
    //this should work with the correct lore
    lore.clear();
    lore.add(ChatColor.LIGHT_PURPLE + "Pick o'Plenty");
    doReturn(lore).when(itemMeta).getLore();
    assertTrue(Pickoplenty.isPick(tool));
}
 
开发者ID:ThePhilderbeast,项目名称:prisonPicks,代码行数:19,代码来源:PickoplentyTest.java

示例5: readUsers

import java.util.ArrayList; //导入方法依赖的package包/类
public ArrayList<Users> readUsers() {
    ArrayList<Users> list = new ArrayList<>();
    try {
        Cursor cursor;
        database = dbHelper.getReadableDatabase();
        cursor = database.rawQuery(DBConstants.SELECT_QUERY, null);
        list.clear();
        if (cursor.getCount() > 0) {
            if (cursor.moveToFirst()) {
                do {
                    String contactId = cursor.getString(cursor.getColumnIndex(DBConstants.CONTACT_ID));
                    String conPerson = cursor.getString(cursor.getColumnIndex(DBConstants.CONTACT_PERSON_NAME));
                    String conNo = cursor.getString(cursor.getColumnIndex(DBConstants.CONTACT_NO));
                    Users users = new Users(contactId,conPerson,conNo);
                    list.add(users);
                } while (cursor.moveToNext());
            }
        }
        cursor.close();
    } catch (Exception e) {
        Log.v("Exception", e.getMessage());
    }
    return list;
}
 
开发者ID:androidmads,项目名称:SQLite2XL,代码行数:25,代码来源:DBQueries.java

示例6: genChildSubsets

import java.util.ArrayList; //导入方法依赖的package包/类
public float genChildSubsets( float cur_SAH, BvhNodeT node, ArrayList<Integer> subset_A, ArrayList<Integer> subset_B){
  int items = node._itemCount();
 
  float   SA_P = 1/node._getAABB().getSurfaceArea();
  float[] SA_A = new float[items-1];
  float[] SA_B = new float[items-1];

  // precompute the arrays of SURFACE AREAS using a sorted! triangle-list. SA_A[]=left->right, and SA_B[]=left<-right
  AABB a = AABB.init(); for(int i = 0;  i < items-1; i++) SA_A[i] = a.grow(obj.f[node._getObjects().get(i  )].aabb).getSurfaceArea();
  AABB b = AABB.init(); for(int i = items-2; i >= 0; i--) SA_B[i] = b.grow(obj.f[node._getObjects().get(i+1)].aabb).getSurfaceArea();
  
  int cur_items_A = -1;
  for(int i = 0, items_A = 1; i < items-1; i++, items_A++){
    float new_SAH = getSAH(SA_P, SA_A[i], items_A, SA_B[i], items-items_A);
    if( new_SAH < cur_SAH ){
      cur_SAH = new_SAH;
      cur_items_A = items_A;
    }
  }

  if( cur_items_A >= 0){ 
    subset_A.clear();  subset_A.addAll(node._getObjects().subList(0,    cur_items_A));     subset_A.trimToSize();
    subset_B.clear();  subset_B.addAll(node._getObjects().subList(cur_items_A, items));    subset_B.trimToSize();
  }
  return cur_SAH;
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:27,代码来源:BvhBuilder.java

示例7: getSentimentSourceTargetMWE

import java.util.ArrayList; //导入方法依赖的package包/类
/**
 * This method is similar to
 * {@link #getSentimentSourceTarget(WordObj, String, WordObj)} except that it
 * deals with multi-word expressions (MWEs). It returns either the
 * corresponding source or the target (depending if it has been called to
 * identify source or target in SentimentChecker class) for a given sentiment
 * expression that is of the 'mwe' type.
 *
 * @param wtmp The word from which the MWE sentiment expression is recognized.
 * @param mwe The sentiment expression (mwe) that is matched.
 * @param label It should be checked whether the sentiment expression has an
 * outgoing node to another node (this would then be the source or the target)
 * with a certain dependency relation specified in this parameter
 * @param containsDeleted If there is a sentiment expression whose
 * corresponding node in the graph of the sentence has been deleted due to
 * normalization, the WordObj parent node (which is still in the graph,
 * necessary to yield existing graph relations) will be stored in this
 * parameter (empty otherwise)
 * @return a list in which the source or the target is stored, empty otherwise
 * if no fitting source/target exists for given label and sent expr
 */
public ArrayList<WordObj> getSentimentSourceTargetMWE(WordObj wtmp, SentimentUnit mwe, String label,
        WordObj containsDeleted) {
  ArrayList<String> mweWords = new ArrayList<String>();
  for (String word : mwe.collocations) {
    mweWords.add(word);
  }

  ArrayList<WordObj> list = new ArrayList<WordObj>();
  ArrayList<WordObj> matches = getMweMatches(wtmp, mweWords, true);
  if (!(matches.size() > mwe.collocations.length)) {
    return new ArrayList<WordObj>();
  }

  for (WordObj mweNode : matches) {
    list.addAll(this.getSentimentSourceTarget(mweNode, label, new WordObj("")));
  }

  // remove doubles
  HashSet<WordObj> hs = new HashSet<WordObj>();
  hs.addAll(list);
  list.clear();
  list.addAll(hs);

  return list;
}
 
开发者ID:artificial-max,项目名称:polcla,代码行数:47,代码来源:DependencyGraph.java

示例8: scheduleNotesForBar

import java.util.ArrayList; //导入方法依赖的package包/类
private void scheduleNotesForBar(final Bar bar, final Date barStartTime) {
    if (noteHandler != null && !bar.countIn){
        List<Note> notes = allNotesInBar(bar);
        // gather chords and schedule for each new start time
        ArrayList<Note> chord = new ArrayList<Note>();
        int lastStartTime = -1;
        for (Note note : notes)
        {
            if (note.start >= 0) // ignore notes with negative start times - these belong to the previous bar
            {
                boolean isChord = (note.start == lastStartTime);
                if (lastStartTime >= 0 && !isChord && chord.size() > 0) // new note time
                {
                    scheduleNoteChangeHandler(lastStartTime, barStartTime, chord);
                    chord.clear();
                }
                chord.add(note);
                lastStartTime = note.start;
            }
        }
        if (chord.size() > 0) // handle last chord in bar
        {
            scheduleNoteChangeHandler(lastStartTime, barStartTime, chord);
        }
    }
}
 
开发者ID:joshschriever,项目名称:LiveNotes,代码行数:27,代码来源:Dispatcher.java

示例9: copyCriteriaOutToIn

import java.util.ArrayList; //导入方法依赖的package包/类
private static void copyCriteriaOutToIn(CriteriaInVO criteriaIn, ArrayList<CriterionInVO> criterionsIn, CriteriaOutVO out) {
	if (criteriaIn != null && criterionsIn != null && out != null) {
		Collection<CriterionOutVO> criterionVOs = out.getCriterions();
		criteriaIn.setCategory(out.getCategory());
		criteriaIn.setId(out.getId());
		criteriaIn.setVersion(out.getVersion());
		criteriaIn.setLabel(out.getLabel());
		criteriaIn.setComment(out.getComment());
		criteriaIn.setModule(out.getModule());
		criteriaIn.setLoadByDefault(out.getLoadByDefault());
		criterionsIn.clear();
		criterionsIn.ensureCapacity(criterionVOs.size());
		Iterator<CriterionOutVO> it = criterionVOs.iterator();
		while (it.hasNext()) {
			CriterionInVO criterionIn = new CriterionInVO();
			copyCriterionOutToIn(criterionIn, it.next());
			criterionsIn.add(criterionIn);
		}
		Collections.sort(criterionsIn, new VOPositionComparator(false));
		normalizeCriterionPositions(criterionsIn);
	}
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:23,代码来源:SearchBeanBase.java

示例10: removeAllChildren

import java.util.ArrayList; //导入方法依赖的package包/类
public void removeAllChildren()
{
	ArrayList<Tag> arr = new ArrayList<Tag>(); 
	TagCursor cur = new TagCursor();
	Tag tag = getFirstChild(cur);
	while(tag != null)
	{
		arr.add(tag);
		tag = getNextChild(cur);
	}
	boolean b = true;
	for(int n=0; b && n<arr.size(); n++)
	{
		tag = arr.get(n);
		removeChild(tag);
	}
	arr.clear();
}
 
开发者ID:costea7,项目名称:ChronoBike,代码行数:19,代码来源:Tag.java

示例11: handlePendingPortStatusMessages

import java.util.ArrayList; //导入方法依赖的package包/类
private void handlePendingPortStatusMessages(OFChannelHandler h, int index)
        throws SwitchStateException {
    if (h.sw == null) {
        String msg = "State machine error: switch is null. Should never " +
                "happen";
        throw new SwitchStateException(msg);
    }
    log.info("Processing {} pending port status messages for {}",
             h.pendingPortStatusMsg.size(), h.sw.getStringId());

    ArrayList<OFPortStatus> temp  = new ArrayList<OFPortStatus>();
    for (OFPortStatus ps: h.pendingPortStatusMsg) {
        temp.add(ps);
        handlePortStatusMessage(h, ps, false);
    }
    // expensive but ok - we don't expect too many port-status messages
    // note that we cannot use clear(), because of the reasons below
    h.pendingPortStatusMsg.removeAll(temp);
    temp.clear();
    // the iterator above takes a snapshot of the list - so while we were
    // dealing with the pending port-status messages, we could have received
    // newer ones. Handle them recursively, but break the recursion after
    // five steps to avoid an attack.
    if (!h.pendingPortStatusMsg.isEmpty() && ++index < 5) {
        handlePendingPortStatusMessages(h, index);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:28,代码来源:OFChannelHandler.java

示例12: optimum

import java.util.ArrayList; //导入方法依赖的package包/类
/**
 * Called to get the best specific destination.
 * <p>
 * <b>only use for condition not mAllowLeaving.</b>
 * <b>only same or similar package name will return.</b>
 * ResolveInfo's priority was highest,
 * if priority equal, same package return.
 * <b>we asume the packagename is xxx.xxx.xxx style.</b>
 */
private ResolveInfo optimum(final List<ResolveInfo> list) {

    if (list == null)
        return null;
    else if (list.size() == 1) {
        return list.get(0);
    }

    final ArrayList<SortedResolveInfo> resolveInfo = new ArrayList<SortedResolveInfo>();

    for (final ResolveInfo info : list) {

        if (!TextUtils.isEmpty(info.activityInfo.packageName)) {
            if (info.activityInfo.packageName.endsWith(mContext.getPackageName())) {
                resolveInfo.add(new SortedResolveInfo(info, info.priority, 1));
            } else {
                final String p1 = info.activityInfo.packageName;
                final String p2 = mContext.getPackageName();
                final String[] l1 = p1.split("\\.");
                final String[] l2 = p2.split("\\.");
                if (l1.length >= 2 && l2.length >= 2) {
                    if (l1[0].equals(l2[0]) && l1[1].equals(l2[1]))
                        resolveInfo.add(new SortedResolveInfo(info, info.priority, 0));
                }
            }
        }
    }

    if (resolveInfo.size() > 0) {
        if (resolveInfo.size() > 1) {
            Collections.sort(resolveInfo);
        }
        final ResolveInfo ret = resolveInfo.get(0).info;
        resolveInfo.clear();
        return ret;
    } else {
        return null;
    }
}
 
开发者ID:lizhangqu,项目名称:support-application,代码行数:49,代码来源:RouteCompat.java

示例13: palette

import java.util.ArrayList; //导入方法依赖的package包/类
private static ArrayList<Integer> palette(Palette p, int defaultColor) {

        ArrayList<Integer> extractedPalette = new ArrayList<>();

        //get all palettes
        Integer lightVibrant, vibrant, darkVibrant, lightMuted, muted, darkMuted;

        lightVibrant = p.getVibrantColor(defaultColor);
        vibrant = p.getVibrantColor(defaultColor);
        darkVibrant = p.getDarkVibrantColor(defaultColor);
        lightMuted = p.getLightMutedColor(defaultColor);
        muted = p.getMutedColor(defaultColor);
        darkMuted = p.getDarkMutedColor(defaultColor);

        extractedPalette.add(lightVibrant);
        extractedPalette.add(vibrant);
        extractedPalette.add(darkVibrant);
        extractedPalette.add(lightMuted);
        extractedPalette.add(muted);
        extractedPalette.add(darkMuted);

        //add also default color, because if the next method fails we have a color anyway
        extractedPalette.add(defaultColor);

        //pass these palettes to a hashset to avoid duplicates
        HashSet<Integer> hashSet = new HashSet<>();
        hashSet.addAll(extractedPalette);

        //add back these values to the palettes array list
        extractedPalette.clear();
        extractedPalette.addAll(hashSet);

        return extractedPalette;
    }
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:35,代码来源:IconColorExtractor.java

示例14: updateCheck

import java.util.ArrayList; //导入方法依赖的package包/类
public static void updateCheck(){
	ArrayList<Shader> checks = new ArrayList<Shader>();
	//filter out dead shaders
	for(Shader shader : shaders.values()){
		if(shader.isDestroyed() && !checks.contains(shader)){
			checks.add(shader);
		}
	}
	//remove all of the dead shaders
	shaders.values().removeAll(checks);
	
	//make sure there aren't any stray references
	checks.clear();
}
 
开发者ID:tek256,项目名称:LD38,代码行数:15,代码来源:Shader.java

示例15: initDirWithJavaFiles

import java.util.ArrayList; //导入方法依赖的package包/类
private void initDirWithJavaFiles(File libDir) throws IOException {

        if (libDir.exists()) {
            recursiveDelete(libDir);
        }
        libDir.mkdirs();
        ArrayList<String> scratchpad = new ArrayList<>();
        scratchpad.add("package lib;");
        scratchpad.add("public class Fbo {");
        scratchpad.add("public static void main(String... args){Foo.f();}");
        scratchpad.add("public static void f(){}");
        scratchpad.add("}");
        createFile(new File(libDir, "Fbo.java"), scratchpad);

        scratchpad.clear();
        scratchpad.add("package lib;");
        scratchpad.add("public class Foo {");
        scratchpad.add("public static void main(String... args){");
        scratchpad.add("for (String x : args) {");
        scratchpad.add("System.out.println(x);");
        scratchpad.add("}");
        scratchpad.add("Fbo.f();");
        scratchpad.add("}");
        scratchpad.add("public static void f(){}");
        scratchpad.add("}");
        createFile(new File(libDir, "Foo.java"), scratchpad);
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:Arrrghs.java


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