当前位置: 首页>>代码示例>>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;未经允许,请勿转载。