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


Java ArrayList.size方法代碼示例

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


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

示例1: collectCells

import java.util.ArrayList; //導入方法依賴的package包/類
protected ArrayList<Object> collectCells() {
    ArrayList<Object> cells = new ArrayList<Object>();

    Platform[] platforms = ShareSDK.getPlatformList();
    if (platforms == null) {
        platforms = new Platform[0];
    }
    HashMap<String, String> hides = getHiddenPlatforms();
    if (hides == null) {
        hides = new HashMap<String, String>();
    }
    for (Platform p : platforms) {
        if (!hides.containsKey(p.getName())) {
            cells.add(p);
        }
    }

    ArrayList<CustomerLogo> customers = getCustomerLogos();
    if (customers != null && customers.size() > 0) {
        cells.addAll(customers);
    }

    return cells;
}
 
開發者ID:gaolhjy,項目名稱:cniao5,代碼行數:25,代碼來源:PlatformPage.java

示例2: a

import java.util.ArrayList; //導入方法依賴的package包/類
private static void a(Context context, JSONObject jSONObject, ArrayList<JSONArray> arrayList) {
    if (arrayList.size() <= 0) {
        b(context);
    }
    JSONArray jSONArray = new JSONArray();
    for (int i = 0; i < arrayList.size(); i++) {
        JSONArray jSONArray2 = (JSONArray) arrayList.get(i);
        for (int i2 = 0; i2 < jSONArray2.length(); i2++) {
            if (jSONArray2.optJSONObject(i2) != null) {
                jSONArray.put(jSONArray2.optJSONObject(i2));
            }
        }
    }
    try {
        jSONObject.put(z[6], jSONArray);
    } catch (JSONException e) {
    }
    a = jSONObject;
    a(context, z[11], jSONObject);
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:21,代碼來源:ac.java

示例3: hasVariableWithNameInBlock

import java.util.ArrayList; //導入方法依賴的package包/類
public boolean hasVariableWithNameInBlock(String value)
{
    ArrayList<VariableDefinition> vd = getVariablesInBlock();
    //System.out.println(vd.size());
    for (int j = 0; j < vd.size(); j++) {
        VariableDefinition get = vd.get(j);
        //System.out.println(get.name+ " vs: "+value);
        if(get.name.equals(value))
            return true;
    }
    return false;
}
 
開發者ID:fesch,項目名稱:Moenagade,代碼行數:13,代碼來源:Element.java

示例4: combine

import java.util.ArrayList; //導入方法依賴的package包/類
/**
 * Generate projection set combined from village that spawned in specific position
 * @param world Target world object
 * @param village Village structures
 * @param chunkX Chunk X coordinate
 * @param chunkZ Chunk Z coordinate
 * @param seed Combination seed
 * @return Array of spawned projections
 */
public static ArrayList<Projection> combine(final UWorld world, final ArrayList<Structure> village, final int chunkX, final int chunkZ, final long seed) {
    ArrayList<Projection> projections = new ArrayList<>();
    Random random = new Random(seed);
    String villageName = village.get(0).getFile().getParent();
    int side = (int) (1 + Math.sqrt(village.size()));
    for (int i = 0, maxSize = 0, offsetX = 0, offsetZ = 0; i < village.size(); ++i) {
        int posX = i % side;
        if (posX == 0) {
            offsetX = 0;
            offsetZ += maxSize;
            maxSize = 0;
        }
        Structure structure = village.get(i);
        int realX = chunkX * 16 + offsetX;
        int realZ = chunkZ * 16 + offsetZ;
        int curSize = Math.max(structure.getWidth(), structure.getLength());
        maxSize = Math.max(maxSize, curSize);
        offsetX += maxSize;
        if (!Limiter.isStructureLimitExceeded(world, structure)) {
            Projection projection = construct(world, realX, realZ, random.nextLong(), structure);
            if (projection != null) {
                projections.add(projection);
                Limiter.useStructure(world, structure);
            }
        }
    }
    new Report().post("VILLAGE", villageName).post("CHUNK", "[X=" + chunkX + ";Z=" + chunkZ + "]").post("TOTAL SPAWNED", String.valueOf(projections.size())).print();
    return projections;
}
 
開發者ID:ternsip,項目名稱:StructPro,代碼行數:39,代碼來源:Village.java

示例5: needsPatching

import java.util.ArrayList; //導入方法依賴的package包/類
@Override
   public boolean needsPatching() {


//Need to check if packages have changed.
ArrayList<File> files = Ln.generateFileList(new File(AVFileVars.AVPackagesDir), false);
try {
    ArrayList<String> last = AVFileVars.getAVPackagesListing();
    if (files.size() != last.size()) {
	if (SPGlobal.logging()) {
	    SPGlobal.logMain(header, "Needs update because number of package files changed.");
	}
	return true;
    }

    for (File f : files) {
	String path = f.getPath();
	if (!last.contains(path)) {
	    if (SPGlobal.logging()) {
		SPGlobal.logMain(header, "Needs update because last package list didn't contain: " + path);
	    }
	    return true;
	}
    }

} catch (IOException ex) {
    SPGlobal.logException(ex);
    return true;
}
return false;
   }
 
開發者ID:tstavrianos,項目名稱:automatic-variants,代碼行數:32,代碼來源:AV.java

示例6: sendBeforeTextChanged

import java.util.ArrayList; //導入方法依賴的package包/類
private void sendBeforeTextChanged(CharSequence text, int start, int before, int after) {
    if (mWatchers != null) {
        final ArrayList<TextWatcher> list = mWatchers;
        final int size = list.size();
        for (int i = 0; i < size; i++) {
            list.get(i).beforeTextChanged(text, start, before, after);
        }
    }
}
 
開發者ID:dkzwm,項目名稱:FormatEditText,代碼行數:10,代碼來源:FormattedEditText.java

示例7: validatePartitionListeners

import java.util.ArrayList; //導入方法依賴的package包/類
private void validatePartitionListeners(final PartitionRegionConfig prconf,
    final PartitionAttributes userPA) {

  ArrayList<String> prconfList = prconf.getPartitionListenerClassNames();

  if (userPA.getPartitionListeners() == null && userPA.getPartitionListeners().length == 0
      && prconfList != null) {
    throw new IllegalStateException(
        LocalizedStrings.PartitionRegionConfigValidator_INCOMPATIBLE_PARTITION_LISTENER
            .toLocalizedString(new Object[] {null, prconfList}));
  }
  if (userPA.getPartitionListeners() != null && prconfList != null) {
    ArrayList<String> userPRList = new ArrayList<String>();
    for (int i = 0; i < userPA.getPartitionListeners().length; i++) {
      userPRList.add(userPA.getPartitionListeners()[i].getClass().getName());
    }

    if (userPA.getPartitionListeners().length != prconfList.size()) {
      throw new IllegalStateException(
          LocalizedStrings.PartitionRegionConfigValidator_INCOMPATIBLE_PARTITION_LISTENER
              .toLocalizedString(new Object[] {userPRList, prconfList}));
    }

    for (String listener : prconfList) {
      if (!(userPRList.contains(listener))) {
        throw new IllegalStateException(
            LocalizedStrings.PartitionRegionConfigValidator_INCOMPATIBLE_PARTITION_LISTENER
                .toLocalizedString(new Object[] {userPRList, prconfList}));
      }
    }
  }
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:33,代碼來源:PartitionRegionConfigValidator.java

示例8: checkSongsEmpty

import java.util.ArrayList; //導入方法依賴的package包/類
public boolean checkSongsEmpty(ArrayList<Song> songs, int pos) {
    if (songs.size() == 0) {
        mAlbums.remove(pos);
        mAdapter.updateData(mAlbums);
        Toast.makeText(mContext, R.string.no_songs_in_this_album, Toast.LENGTH_SHORT).show();
        return true;
    }
    return false;
}
 
開發者ID:reyanshmishra,項目名稱:Rey-MusicPlayer,代碼行數:10,代碼來源:TracksSubGridViewFragment.java

示例9: findCastableLocs

import java.util.ArrayList; //導入方法依賴的package包/類
public static ArrayList<Location> findCastableLocs(Location origin, double radius, int count) {
    ArrayList<Location> locs = new ArrayList<Location>();
    if (radius < 0)
        radius = -radius;
    int cap = count * 2; // max number of spots to try to find valid locations at
    for (int k = 0; k < cap; k++) {
        double dx = RMath.randDouble(-radius, radius);
        double dz = RMath.randDouble(-radius, radius);
        origin.add(dx, 0, dz);
        for (int dy = 0; dy <= 3; dy++) {
            Location temp = origin.clone().add(0, dy, 0);
            if (checkLocation(temp)) {
                locs.add(temp);
                break;
            } else {
                if (checkLocation(temp.add(0, -dy * 2, 0))) {
                    locs.add(temp);
                    break;
                }
            }
        }
        if (locs.size() >= count)
            break;
    }
    if (locs.size() < count) {
        System.out.println("WARNING: findCastableLocs() at " + origin + " failed to find " + count + " locations in a radius of " + radius + ". " + locs.size() + " locations were found.");
    }
    return locs;
}
 
開發者ID:edasaki,項目名稱:ZentrelaCore,代碼行數:30,代碼來源:RLocation.java

示例10: updateAllContent

import java.util.ArrayList; //導入方法依賴的package包/類
@Override
public void updateAllContent(ArrayList<AppContent> items) {
    if (currentNavigationViewMenu.size() > 0)
        currentNavigationViewMenu.clear();

    this.items = items;

    if (!InternetUtils.isInternetAvailable(this))
        Snackbar.make(findViewById(R.id.main_coordinator_layout), R.string.snackbar_cache_text,
                Snackbar.LENGTH_LONG).show();

    if (items == null) {
        handleInternetError(null);
        return;
    }

    for (int i = 0; i < items.size(); i++) {
        AppContent item = items.get(i);
        menuIdPosition.put(item.getContent_id(), i);
        if (AppmaticUtils.getIconRes(item.getIcon_id(), this) == -1)
            currentNavigationViewMenu.add(R.id.main_group_menu, item.getContent_id(), i, item.getName());
        else
            currentNavigationViewMenu.add(R.id.main_group_menu, item.getContent_id(), i,
                    item.getName()).setIcon(AppmaticUtils.getIconRes(item.getIcon_id(), this));
    }

    mainPresenter.getExtraItems();
}
 
開發者ID:Nulltilus,項目名稱:Appmatic-Android,代碼行數:29,代碼來源:MainActivity.java

示例11: methodSignatureArgumentTypes

import java.util.ArrayList; //導入方法依賴的package包/類
/**
 * @param  signature    Method signature
 * @param chopit Shorten class names ?
 * @return Array of argument types
 * @throws  ClassFormatException
 */
public static final String[] methodSignatureArgumentTypes(String signature,
                                                          boolean chopit)
  throws ClassFormatException
{
  ArrayList vec = new ArrayList();
  int       index;
  String[]  types;

  try { // Read all declarations between for `(' and `)'
    if(signature.charAt(0) != '(')
      throw new ClassFormatException("Invalid method signature: " + signature);

    index = 1; // current string position

    while(signature.charAt(index) != ')') {
      vec.add(signatureToString(signature.substring(index), chopit));
      index += consumed_chars; // update position
    }
  } catch(StringIndexOutOfBoundsException e) { // Should never occur
    throw new ClassFormatException("Invalid method signature: " + signature);
  }

  types = new String[vec.size()];
  vec.toArray(types);
  return types;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:33,代碼來源:Utility.java

示例12: onSuccess

import java.util.ArrayList; //導入方法依賴的package包/類
public void onSuccess(API api, int action, Map<String, Object> result) {
    ArrayList<HashMap<String, Object>> res = forceCast(result.get("result"));
    if (null != res && res.size() > 0) {
        categoryList.clear();
        categoryList.addAll(res);
        categoryAdapter.notifyDataSetChanged();
    }
}
 
開發者ID:stytooldex,項目名稱:stynico,代碼行數:9,代碼來源:WxArticleAPIActivity.java

示例13: AutoComplete

import java.util.ArrayList; //導入方法依賴的package包/類
public String AutoComplete(ArrayList<String> comm, int nv) {
    if (nv > comm.size() - 1) {
        return "";
    }
    String tmp = comm.get(nv);
    String res = getBestCMD(tmp);
    if (res.isEmpty()) {
        return tmp;
    }
    if (isCMDTipoVariavel()) {
        res = tmp;
    }

    nv++;
    if (nv == comm.size()) {
        if (Proximos.isEmpty()) {
            return res;
        }
        return res + " ";
    }

    int tmpnv = nv;
    Sintaxe prx = null;
    for (Sintaxe sx : Proximos) {
        int idx = sx.getNivelDeValidade(comm, nv);
        if (idx > tmpnv) {
            tmpnv = idx;
            prx = sx;
        }
    }
    if (prx == null) {
        return res + " " + comm.get(nv);
    }
    return res + " " + prx.AutoComplete(comm, nv);
}
 
開發者ID:chcandido,項目名稱:brModelo,代碼行數:36,代碼來源:Sintaxe.java

示例14: readObject

import java.util.ArrayList; //導入方法依賴的package包/類
/**
 * Reconstitutes this map from a stream (that is, deserializes it).
 * @param s the stream
 * @throws ClassNotFoundException if the class of a serialized object
 *         could not be found
 * @throws java.io.IOException if an I/O error occurs
 */
@SuppressWarnings("unchecked")
private void readObject(final java.io.ObjectInputStream s)
    throws java.io.IOException, ClassNotFoundException {
    // Read in the Comparator and any hidden stuff
    s.defaultReadObject();
    // Reset transients
    initialize();

    /*
     * This is nearly identical to buildFromSorted, but is
     * distinct because readObject calls can't be nicely adapted
     * as the kind of iterator needed by buildFromSorted. (They
     * can be, but doing so requires type cheats and/or creation
     * of adaptor classes.) It is simpler to just adapt the code.
     */

    HeadIndex<K,V> h = head;
    Node<K,V> basepred = h.node;
    ArrayList<Index<K,V>> preds = new ArrayList<Index<K,V>>();
    for (int i = 0; i <= h.level; ++i)
        preds.add(null);
    Index<K,V> q = h;
    for (int i = h.level; i > 0; --i) {
        preds.set(i, q);
        q = q.down;
    }

    for (;;) {
        Object k = s.readObject();
        if (k == null)
            break;
        Object v = s.readObject();
        if (v == null)
            throw new NullPointerException();
        K key = (K) k;
        V val = (V) v;
        int rnd = ThreadLocalRandom.current().nextInt();
        int j = 0;
        if ((rnd & 0x80000001) == 0) {
            do {
                ++j;
            } while (((rnd >>>= 1) & 1) != 0);
            if (j > h.level) j = h.level + 1;
        }
        Node<K,V> z = new Node<K,V>(key, val, null);
        basepred.next = z;
        basepred = z;
        if (j > 0) {
            Index<K,V> idx = null;
            for (int i = 1; i <= j; ++i) {
                idx = new Index<K,V>(z, idx, null);
                if (i > h.level)
                    h = new HeadIndex<K,V>(h.node, h, idx, i);

                if (i < preds.size()) {
                    preds.get(i).right = idx;
                    preds.set(i, idx);
                } else
                    preds.add(idx);
            }
        }
    }
    head = h;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:72,代碼來源:ConcurrentSkipListMap.java

示例15: doLevelUp

import java.util.ArrayList; //導入方法依賴的package包/類
public void doLevelUp(Score score) {
    if (getLevel() < getEffectiveLevel()){

        Score[] choices = {Score.SKILL, Score.WILL, Score.MIGHT, Score.WITS};
        ArrayList<Score> possibleScores = new ArrayList<>();
        for (Score selectScore: choices) {
            if(getCharacter().canAddToScore(selectScore)) {
                possibleScores.add(selectScore);
            }
        }

        Score selectedScore;
        if (possibleScores.contains(score)) {
            selectedScore = score;
        } else {
            selectedScore = possibleScores.get(rollDice.roll(possibleScores.size()) - 1);
        }

        if (possibleScores.size() > 0) {
            while (!getCharacter().canAddToScore(selectedScore)) {
                selectedScore = possibleScores.get((possibleScores.indexOf(selectedScore) + 1) % possibleScores.size());
            }
        }

        // Contains information about changed scores
        HashMap<Score, Integer> levelData = new HashMap<>();

        if (getCharacter().canAddToScore(Score.LUCK)) {
            AttributeScore luck = getCharacter().getScore(Score.LUCK);
            levelData.put(Score.LUCK, luck.getScore());
            luck.setScore(luck.getScore() + 1);
        } else {
            levelData.put(Score.LUCK, 20);
        }

        AttributeScore selectedAttrScore = getCharacter().getScore(selectedScore);

        levelData.put(selectedScore, selectedAttrScore.getScore());
        getScoreLevelChoice().add(levelData);

        selectedAttrScore.setScore(selectedAttrScore.getScore() + 2);
        setAddedHits(getAddedHits() + 2);

        setLevel(getLevel() + 1);
        getCharacter().validateScores();
    }
}
 
開發者ID:CIS-Extra,項目名稱:mazes_and_minotaurs,代碼行數:48,代碼來源:Priest.java


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