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