當前位置: 首頁>>代碼示例>>Java>>正文


Java ArrayList.remove方法代碼示例

本文整理匯總了Java中java.util.ArrayList.remove方法的典型用法代碼示例。如果您正苦於以下問題:Java ArrayList.remove方法的具體用法?Java ArrayList.remove怎麽用?Java ArrayList.remove使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.ArrayList的用法示例。


在下文中一共展示了ArrayList.remove方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: drawLines

import java.util.ArrayList; //導入方法依賴的package包/類
void drawLines(Graphics2D g, int cap) {
  final ArrayList<LineDefinition> lds =
    new ArrayList<LineDefinition>(Arrays.asList(lineDefinitions));

  // find the next line in priority
  while (lds.size() > 0) {
    LineDefinition lowest = null;
    for (LineDefinition ld : lds) {
      if (ld == null)
        continue;
      else if (lowest == null || compare(ld, lowest) < 0)
        lowest = ld;
    }
    if (lowest == null)
      break;
    else {
      lowest.draw(g, cap);
      lowest.clearPoints();
      lds.remove(lowest);
    }
  }
}
 
開發者ID:ajmath,項目名稱:VASSAL-src,代碼行數:23,代碼來源:MapBoard.java

示例2: bindScreens

import java.util.ArrayList; //導入方法依賴的package包/類
@Override
public void bindScreens(ArrayList<Long> orderedScreenIds) {
    // Make sure the first screen is always at the start.
    if (FeatureFlags.QSB_ON_FIRST_SCREEN &&
            orderedScreenIds.indexOf(Workspace.FIRST_SCREEN_ID) != 0) {
        orderedScreenIds.remove(Workspace.FIRST_SCREEN_ID);
        orderedScreenIds.add(0, Workspace.FIRST_SCREEN_ID);
        mModel.updateWorkspaceScreenOrder(this, orderedScreenIds);
    } else if (!FeatureFlags.QSB_ON_FIRST_SCREEN && orderedScreenIds.isEmpty()) {
        // If there are no screens, we need to have an empty screen
        mWorkspace.addExtraEmptyScreen();
    }
    bindAddScreens(orderedScreenIds);

    // Create the custom content page (this call updates mDefaultScreen which calls
    // setCurrentPage() so ensure that all pages are added before calling this).
    if (hasCustomContentToLeft()) {
        mWorkspace.createCustomContentContainer();
        populateCustomContentContainer();
    }

    // After we have added all the screens, if the wallpaper was locked to the default state,
    // then notify to indicate that it can be released and a proper wallpaper offset can be
    // computed before the next layout
    mWorkspace.unlockWallpaperFromDefaultPageOnNextLayout();
}
 
開發者ID:michelelacorte,項目名稱:FlickLauncher,代碼行數:27,代碼來源:Launcher.java

示例3: buildShuffledPlayList

import java.util.ArrayList; //導入方法依賴的package包/類
private void buildShuffledPlayList() {
    if (playlist.isEmpty()) {
        return;
    }
    ArrayList<MessageObject> all = new ArrayList<>(playlist);
    shuffledPlaylist.clear();

    MessageObject messageObject = playlist.get(currentPlaylistNum);
    all.remove(currentPlaylistNum);
    shuffledPlaylist.add(messageObject);

    int count = all.size();
    for (int a = 0; a < count; a++) {
        int index = Utilities.random.nextInt(all.size());
        shuffledPlaylist.add(all.get(index));
        all.remove(index);
    }
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:19,代碼來源:MediaController.java

示例4: addPrintServiceToList

import java.util.ArrayList; //導入方法依賴的package包/類
private int addPrintServiceToList(ArrayList<PrintService> printerList, PrintService ps) {
    int index = printerList.indexOf(ps);
    // Check if PrintService with same name is already in the list.
    if (CUPSPrinter.isCupsRunning() && index != -1) {
        // Bug in Linux: Duplicate entry of a remote printer
        // and treats it as local printer but it is returning wrong
        // information when queried using IPP. Workaround is to remove it.
        // Even CUPS ignores these entries as shown in lpstat or using
        // their web configuration.
        PrinterURI uri = ps.getAttribute(PrinterURI.class);
        if (uri.getURI().getHost().equals("localhost")) {
            IPPPrintService.debug_println(debugPrefix+"duplicate PrintService, ignoring the new local printer: "+ps);
            return index;  // Do not add this.
        }
        PrintService oldPS = printerList.get(index);
        uri = oldPS.getAttribute(PrinterURI.class);
        if (uri.getURI().getHost().equals("localhost")) {
            IPPPrintService.debug_println(debugPrefix+"duplicate PrintService, removing existing local printer: "+oldPS);
            printerList.remove(oldPS);
        } else {
            return index;
        }
    }
    printerList.add(ps);
    return (printerList.size() - 1);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:27,代碼來源:PrintServiceLookupProvider.java

示例5: main

import java.util.ArrayList; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    //напишите тут ваш код
    ArrayList<String> list = new ArrayList<String>();

    Scanner sc = new Scanner(System.in);


    for (int i = 0; i < 5; i++) {
        list.add(sc.nextLine());
    }

    String tmp;
    for (int i = 0; i < 13; i++) {
        tmp = list.get(list.size()-1);
        list.add(0,tmp);
        list.remove(list.size()-1);
    }



    for (int i = 0; i < 5; i++) {
        System.out.println(list.get(i));
    }
}
 
開發者ID:avedensky,項目名稱:JavaRushTasks,代碼行數:25,代碼來源:Solution.java

示例6: cancelQueueListener

import java.util.ArrayList; //導入方法依賴的package包/類
/**
 * Cancel queue event notification listener.
 * @param listener
 */
@Override
public void cancelQueueListener(MessageQueueListener listener ) {
  try{  listeners_mon.enter();
    //copy-on-write
    ArrayList new_list = new ArrayList( listeners );
    new_list.remove( listener );
    listeners = new_list;
  }
  finally{  listeners_mon.exit();  }
}
 
開發者ID:BiglySoftware,項目名稱:BiglyBT,代碼行數:15,代碼來源:IncomingMessageQueueImpl.java

示例7: Fin_Exe_proc

import java.util.ArrayList; //導入方法依賴的package包/類
public ArrayList<Processus> Fin_Exe_proc(ArrayList<Processus> list_pro_Exe, String algo, int time) {
    if (time_Exe_proc == 0) {  // condiiton ajouter du a un problem de simulation car programme il faut que exe il n'a pas 
        //intelligence car quand P1 sort terminer  est subtiment P2 arrive cette condition regle se problem dans la boucle  while au Fin  Exe pro est appeller 
        switch (algo) {
            case "FCFS":
                list_pro_Exe.get(0).setTempFin(time);

                fenetre_execute.add_Exe_Table(list_pro_Exe.get(0).getNomPre(), "", String.valueOf(list_pro_Exe.get(0).getTempFin()), "Terminer");
                fenetre_execute.add_diagramme(list_pro_Exe.get(max).getNomPre(), 0, time);
                list_pro_Exe.remove(0);

                break;

            case "SJF":

                list_pro_Exe.get(min).setTempFin(time);
                fenetre_execute.add_Exe_Table(list_pro_Exe.get(min).getNomPre(), "", String.valueOf(list_pro_Exe.get(min).getTempFin()), "Terminer");
                fenetre_execute.add_diagramme(list_pro_Exe.get(max).getNomPre(), 0, time);
                list_pro_Exe.remove(min);
                break;

            case "Priority":
                list_pro_Exe.get(max).setTempFin(time); // initialiser temp fin de processus terminer
                fenetre_execute.add_Exe_Table(list_pro_Exe.get(max).getNomPre(), "", String.valueOf(list_pro_Exe.get(max).getTempFin()), "Terminer");
                fenetre_execute.add_diagramme(list_pro_Exe.get(max).getNomPre(), 0, time);
                list_pro_Exe.remove(max); // elever processus de la liste

                break;

        }
    }

    return list_pro_Exe;
}
 
開發者ID:MF1996,項目名稱:Scheduler-Marwa-slafa-FEHIM-Mahfoud-,代碼行數:35,代碼來源:Scheduler.java

示例8: normalizePath

import java.util.ArrayList; //導入方法依賴的package包/類
/**
 * Removes multiple repeated //s, and collapses processes ../s.
 */
protected static String normalizePath(String rawPath) {
    // If this is an absolute path, trim the leading "/" and replace it later
    boolean isAbsolutePath = rawPath.startsWith("/");
    if (isAbsolutePath) {
        rawPath = rawPath.replaceFirst("/+", "");
    }
    ArrayList<String> components = new ArrayList<String>(Arrays.asList(rawPath.split("/+")));
    for (int index = 0; index < components.size(); ++index) {
        if (components.get(index).equals("..")) {
            components.remove(index);
            if (index > 0) {
                components.remove(index-1);
                --index;
            }
        }
    }
    StringBuilder normalizedPath = new StringBuilder();
    for(String component: components) {
        normalizedPath.append("/");
        normalizedPath.append(component);
    }
    if (isAbsolutePath) {
        return normalizedPath.toString();
    } else {
        return normalizedPath.toString().substring(1);
    }
}
 
開發者ID:SUTFutureCoder,項目名稱:localcloud_fe,代碼行數:31,代碼來源:Filesystem.java

示例9: remove

import java.util.ArrayList; //導入方法依賴的package包/類
/**
 * Removes the entry for {@code key} if it exists.
 *
 * @return the previous value mapped by {@code key}.
 */
public final BitmapDrawable remove(String key) {
    if (key == null) {
        throw new NullPointerException("key == null");
    }

    BitmapDrawable previous;
    synchronized (this) {
        previous = map.remove(key);
        if (previous != null) {
            size -= safeSizeOf(key, previous);
        }
    }

    if (previous != null) {
        String[] args = key.split("@");
        if (args.length > 1) {
            ArrayList<String> arr = mapFilters.get(args[0]);
            if (arr != null) {
                arr.remove(args[1]);
                if (arr.isEmpty()) {
                    mapFilters.remove(args[0]);
                }
            }
        }

        entryRemoved(false, key, previous, null);
    }

    return previous;
}
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:36,代碼來源:LruCache.java

示例10: getPeers

import java.util.ArrayList; //導入方法依賴的package包/類
public Iterable<Node> getPeers(int k) {
	if (this.partialView.size() == k || k == Integer.MAX_VALUE) {
		return this.getPeers();
	} else {
		HashBag<Node> sample = new HashBag<Node>();
		ArrayList<Node> clone = new ArrayList<Node>(this.partialView);
		while (sample.size() < Math.min(k, this.partialView.size())) {
			int rn = CommonState.r.nextInt(clone.size());
			sample.add(clone.get(rn));
			clone.remove(rn);
		}
		return sample;
	}
}
 
開發者ID:Chat-Wane,項目名稱:peersim-pcbroadcast,代碼行數:15,代碼來源:PartialView.java

示例11: VerticalCycleAdapter

import java.util.ArrayList; //導入方法依賴的package包/類
public VerticalCycleAdapter(Context context)
{
    this.context=context;
    sharedPreferences=context.getSharedPreferences("MYSHAREDPREFERENCES",MODE_PRIVATE);
    String mip=sharedPreferences.getString("mip","lol");
    String interests=sharedPreferences.getString("interests","lol");
    String mydomain=sharedPreferences.getString("mydomain","Nodomain");
    ArrayList<String> my_interests=new ArrayList<>();
    StringTokenizer st1=new StringTokenizer(interests,",");
    if(mydomain.equals("null"))
    {
        mydomain="Programming";
    }
    my_interests.add(mydomain);
    while (st1.hasMoreTokens())
    {
        String token=st1.nextToken();
        my_interests.add(token);
    }

    my_interests.remove("Tech");
    for(int i=0;i<NewsPOGO.newsArray.size();i++)
    {
        String types=NewsPOGO.newsArray.get(i).types;
        for(int j=0;j<my_interests.size();j++)
        if(NewsPOGO.newsArray.get(i).types.contains(my_interests.get(j)))
        {
            filteredNews.add(NewsPOGO.newsArray.get(i));
            Log.d("interests", "VerticalCycleAdapter: "+my_interests.get(j)+"  "+NewsPOGO.newsArray.get(i).body.substring(0,20));
            break;
        }
    }
}
 
開發者ID:goutham-kalikrishna,項目名稱:ShotsNewsApp,代碼行數:34,代碼來源:VerticalCycleAdapter.java

示例12: listSwapItem

import java.util.ArrayList; //導入方法依賴的package包/類
/**
 * two items in a list of data exchange
 * @author leibing
 * @createTime 2016/12/3
 * @lastModify 2016/12/3
 * @param mList
 * @param swapNum1
 * @param swapNum2
 * @return
 */
public static void listSwapItem(ArrayList mList, int swapNum1, int swapNum2){
	// if no data,just return it
	if (mList == null || mList.size() == 0)
		return;
	// if the index cross-border,just return it
	if (swapNum1 >= mList.size() || swapNum2 >= mList.size())
		return;
	// swap data manipulation
	mList.add(swapNum1, mList.get(swapNum2));
	mList.add(swapNum2 + 1, mList.get(swapNum1 + 1));
	mList.remove(swapNum1 + 1);
	mList.remove(swapNum2 + 1);
}
 
開發者ID:leibing8912,項目名稱:JkImageLoader,代碼行數:24,代碼來源:StringUtils.java

示例13: compress

import java.util.ArrayList; //導入方法依賴的package包/類
/**
 * Performs path compress on the DFS info.
 *
 * @param in Basic block whose DFS info we are path compressing.
 */
private void compress(SsaBasicBlock in) {
    DFSInfo bbInfo = info[in.getIndex()];
    DFSInfo ancestorbbInfo = info[bbInfo.ancestor.getIndex()];

    if (ancestorbbInfo.ancestor != null) {
        ArrayList<SsaBasicBlock> worklist = new ArrayList<SsaBasicBlock>();
        HashSet<SsaBasicBlock> visited = new HashSet<SsaBasicBlock>();
        worklist.add(in);

        while (!worklist.isEmpty()) {
            int wsize = worklist.size();
            SsaBasicBlock v = worklist.get(wsize - 1);
            DFSInfo vbbInfo = info[v.getIndex()];
            SsaBasicBlock vAncestor = vbbInfo.ancestor;
            DFSInfo vabbInfo = info[vAncestor.getIndex()];

            // Make sure we process our ancestor before ourselves.
            if (visited.add(vAncestor) && vabbInfo.ancestor != null) {
                worklist.add(vAncestor);
                continue;
            }
            worklist.remove(wsize - 1);

            // Update based on ancestor info.
            if (vabbInfo.ancestor == null) {
                continue;
            }
            SsaBasicBlock vAncestorRep = vabbInfo.rep;
            SsaBasicBlock vRep = vbbInfo.rep;
            if (info[vAncestorRep.getIndex()].semidom
                    < info[vRep.getIndex()].semidom) {
                vbbInfo.rep = vAncestorRep;
            }
            vbbInfo.ancestor = vabbInfo.ancestor;
        }
    }
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:43,代碼來源:Dominators.java

示例14: toPackageName

import java.util.ArrayList; //導入方法依賴的package包/類
/**
 * Computes a Java package name from a namespace URI,
 * as specified in the spec.
 *
 * @return
 *      null if it fails to derive a package name.
 */
public String toPackageName( String nsUri ) {
    // remove scheme and :, if present
    // spec only requires us to remove 'http' and 'urn'...
    int idx = nsUri.indexOf(':');
    String scheme = "";
    if(idx>=0) {
        scheme = nsUri.substring(0,idx);
        if( scheme.equalsIgnoreCase("http") || scheme.equalsIgnoreCase("urn") )
            nsUri = nsUri.substring(idx+1);
    }

    // tokenize string
    ArrayList<String> tokens = tokenize( nsUri, "/: " );
    if( tokens.size() == 0 ) {
        return null;
    }

    // remove trailing file type, if necessary
    if( tokens.size() > 1 ) {
        // for uri's like "www.foo.com" and "foo.com", there is no trailing
        // file, so there's no need to look at the last '.' and substring
        // otherwise, we loose the "com" (which would be wrong)
        String lastToken = tokens.get( tokens.size()-1 );
        idx = lastToken.lastIndexOf( '.' );
        if( idx > 0 ) {
            lastToken = lastToken.substring( 0, idx );
            tokens.set( tokens.size()-1, lastToken );
        }
    }

    // tokenize domain name and reverse.  Also remove :port if it exists
    String domain = tokens.get( 0 );
    idx = domain.indexOf(':');
    if( idx >= 0) domain = domain.substring(0, idx);
    ArrayList<String> r = reverse( tokenize( domain, scheme.equals("urn")?".-":"." ) );
    if( r.get( r.size()-1 ).equalsIgnoreCase( "www" ) ) {
        // remove leading www
        r.remove( r.size()-1 );
    }

    // replace the domain name with tokenized items
    tokens.addAll( 1, r );
    tokens.remove( 0 );

    // iterate through the tokens and apply xml->java name algorithm
    for( int i = 0; i < tokens.size(); i++ ) {

        // get the token and remove illegal chars
        String token = tokens.get( i );
        token = removeIllegalIdentifierChars( token );

        // this will check for reserved keywords
        if (SourceVersion.isKeyword(token.toLowerCase())) {
            token = '_' + token;
        }

        tokens.set( i, token.toLowerCase() );
    }

    // concat all the pieces and return it
    return combine( tokens, '.' );
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:70,代碼來源:NameConverter.java

示例15: testOOM

import java.util.ArrayList; //導入方法依賴的package包/類
@Test
public void testOOM() throws IOException, InterruptedException, KeeperException {
    // This test takes too long tos run!
    if (true)
        return;
    File tmpDir = ClientBase.createTmpDir();
    // Grab some memory so that it is easier to cause an
    // OOM condition;
    ArrayList<byte[]> hog = new ArrayList<byte[]>();
    while (true) {
        try {
            hog.add(new byte[1024 * 1024 * 2]);
        } catch (OutOfMemoryError e) {
            hog.remove(0);
            break;
        }
    }
    ClientBase.setupTestEnv();
    ZooKeeperServer zks = new ZooKeeperServer(tmpDir, tmpDir, 3000);

    final int PORT = PortAssignment.unique();
    ServerCnxnFactory f = ServerCnxnFactory.createFactory(PORT, -1);
    f.startup(zks);
    Assert.assertTrue("waiting for server up",
               ClientBase.waitForServerUp("127.0.0.1:" + PORT,
                                          CONNECTION_TIMEOUT));

    System.err.println("OOM Stage 0");
    utestPrep(PORT);
    System.out.println("Free = " + Runtime.getRuntime().freeMemory()
            + " total = " + Runtime.getRuntime().totalMemory() + " max = "
            + Runtime.getRuntime().maxMemory());
    System.err.println("OOM Stage 1");
    for (int i = 0; i < 1000; i++) {
        System.out.println(i);
        utestExists(PORT);
    }
    System.out.println("Free = " + Runtime.getRuntime().freeMemory()
            + " total = " + Runtime.getRuntime().totalMemory() + " max = "
            + Runtime.getRuntime().maxMemory());
    System.err.println("OOM Stage 2");
    for (int i = 0; i < 1000; i++) {
        System.out.println(i);
        utestGet(PORT);
    }
    System.out.println("Free = " + Runtime.getRuntime().freeMemory()
            + " total = " + Runtime.getRuntime().totalMemory() + " max = "
            + Runtime.getRuntime().maxMemory());
    System.err.println("OOM Stage 3");
    for (int i = 0; i < 1000; i++) {
        System.out.println(i);
        utestChildren(PORT);
    }
    System.out.println("Free = " + Runtime.getRuntime().freeMemory()
            + " total = " + Runtime.getRuntime().totalMemory() + " max = "
            + Runtime.getRuntime().maxMemory());
    hog.get(0)[0] = (byte) 1;

    f.shutdown();
    zks.shutdown();
    Assert.assertTrue("waiting for server down",
               ClientBase.waitForServerDown("127.0.0.1:" + PORT,
                                            CONNECTION_TIMEOUT));
}
 
開發者ID:l294265421,項目名稱:ZooKeeper,代碼行數:65,代碼來源:OOMTest.java


注:本文中的java.util.ArrayList.remove方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。