Java Code Examples for java.util.Collections#fill()

The following examples show how to use java.util.Collections#fill() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public static void main(String[] args) {
    //create a ArrayList object
    ArrayList arrayList = new ArrayList();

    //Add elements to ArrayList
    arrayList.add("A");
    arrayList.add("B");
    arrayList.add("D");

/*
  To replace all elements of Java ArrayList with specified element use,
  static void fill(List list, Object element) method of Collections class.
*/

    System.out.println("Before replacement, ArrayList contains : " + arrayList);

    Collections.fill(arrayList, "REPLACED");

    System.out.println("After replacement, ArrayList contains : " + arrayList);
}
 
Example 2
public static void main(String[] args) {
    //create a Vector object
    Vector v = new Vector();

    //Add elements to Vector
    v.add("A");
    v.add("B");
    v.add("D");

/*
  To replace all elements of Java Vector with specified element use,
  static void fill(List list, Object element) method of Collections class.
*/

    System.out.println("Before replacement, Vector contains : " + v);

    Collections.fill(v, "REPLACED");

    System.out.println("After replacement, Vector contains : " + v);
}
 
Example 3
private void replaceStackMoves(List<LIRInstruction> instructions) {
    int size = dst.size();
    if (size > 1) {
        AMD64MultiStackMove multiMove = new AMD64MultiStackMove(dst.toArray(new AllocatableValue[size]), src.toArray(new AllocatableValue[size]), reg, slot);
        // replace first instruction
        instructions.set(begin, multiMove);
        // and null out others
        Collections.fill(instructions.subList(begin + 1, begin + size), null);
        // removed
        removed = true;
        eliminatedBackup.add(size - 1);
    }
    // reset
    dst.clear();
    src.clear();
    begin = NONE;
    reg = null;
    slot = null;
}
 
Example 4
Source Project: J2ME-Loader   File: List.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onItemClick(AdapterView parent, View view, int position, long id) {
	selectedIndex = position;
	switch (listType) {
		case IMPLICIT:
			fireCommandAction(selectCommand, List.this);
			break;
		case EXCLUSIVE:
			if (position >= 0 && position < selected.size()) {
				Collections.fill(selected, Boolean.FALSE);
				selected.set(position, Boolean.TRUE);
			}
			break;
		case MULTIPLE:
			if (position >= 0 && position < selected.size()) {
				selected.set(position, !selected.get(position));
			}
			break;
	}
	adapter.notifyDataSetChanged();
}
 
Example 5
public boolean registerLogin(int accountId) {
    List<Long> accHist = loginHistory.get(accountId);
    if (accHist == null) {
        accHist = new LinkedList<Long>();
        loginHistory.put(accountId, accHist);
    }
    
    synchronized (accHist) {
        if (accHist.size() > YamlConfig.config.server.MAX_ACCOUNT_LOGIN_ATTEMPT) {
            long blockExpiration = Server.getInstance().getCurrentTime() + YamlConfig.config.server.LOGIN_ATTEMPT_DURATION;
            Collections.fill(accHist, blockExpiration);

            return false;
        }
        
        accHist.add(Server.getInstance().getCurrentTime() + YamlConfig.config.server.LOGIN_ATTEMPT_DURATION);
        return true;
    }
}
 
Example 6
public PhoenixPreparedStatement(PhoenixConnection connection, PhoenixStatementParser parser) throws SQLException,
        IOException {
    super(connection);
    this.statement = parser.nextStatement(new ExecutableNodeFactory());
    if (this.statement == null) { throw new EOFException(); }
    this.query = null; // TODO: add toString on SQLStatement
    this.parameters = Arrays.asList(new Object[statement.getBindCount()]);
    Collections.fill(parameters, BindManager.UNBOUND_PARAMETER);
}
 
Example 7
public PhoenixPreparedStatement(PhoenixConnection connection, String query) throws SQLException {
    super(connection);
    this.query = query;
    this.statement = parseStatement(query);
    this.parameters = Arrays.asList(new Object[statement.getBindCount()]);
    Collections.fill(parameters, BindManager.UNBOUND_PARAMETER);
}
 
Example 8
Source Project: HaloDB   File: OffHeapHashTableImpl.java    License: Apache License 2.0 5 votes vote down vote up
public void close() {
    closed = true;
    for (Segment map : segments) {
        map.release();
    }
    Collections.fill(segments, null);

    if (logger.isDebugEnabled()) {
        logger.debug("Closing OHC instance");
    }
}
 
Example 9
/**
 * Create an new rows flusher
 * Warning, consume the rows by removing the refs.
 *
 * @param xmlUtil   an util
 * @param tableRows a view on the rows
 * @return the flusher
 * @throws IOException if an I/O error occurs
 */
public static PreprocessedRowsFlusher create(final XMLUtil xmlUtil,
                                             final List<TableRowImpl> tableRows)
        throws IOException {
    // create a char sequence
    final StringBuilder sb = new StringBuilder(STRING_BUILDER_SIZE);
    for (final TableRowImpl row : tableRows) {
        TableRowImpl.appendXMLToTable(row, xmlUtil, sb);
    }
    // free rows
    Collections.fill(tableRows, null);

    return new PreprocessedRowsFlusher(sb);
}
 
Example 10
@Override
public void flushInto(final XMLUtil xmlUtil, final ZipUTF8Writer writer) throws IOException {
    // flush rows
    for (final TableRowImpl row : this.rows) {
        if (row == null) {
            throw new IllegalArgumentException();
        }
        row.appendXMLToTable(xmlUtil, writer);
    }
    // free rows
    Collections.fill(this.rows, null);
}
 
Example 11
@Override
public void flushInto(final XMLUtil xmlUtil, final ZipUTF8Writer writer) throws IOException {
    for (final TableRowImpl row : this.rows) {
        TableRowImpl.appendXMLToTable(row, xmlUtil, writer);
    }
    // free rows
    Collections.fill(this.rows, null);
    this.appender.appendPostamble(writer);
}
 
Example 12
public ToggleComponentsArrayAdapter(Context context, int resource, List<ResolveInfo> objects) {
    super(context, resource, objects);
    mPackageManager = context.getPackageManager();
    mDevicePolicyManager = (DevicePolicyManager) context.getSystemService(
            Context.DEVICE_POLICY_SERVICE);
    // Init mIsComponentCheckedList
    mIsComponentCheckedList = new ArrayList<>(Arrays.asList(new Boolean[objects.size()]));
    Collections.fill(mIsComponentCheckedList, Boolean.FALSE);
}
 
Example 13
public PhoenixPreparedStatement(PhoenixConnection connection, PhoenixStatementParser parser) throws SQLException,
        IOException {
    super(connection);
    this.statement = parser.nextStatement(new ExecutableNodeFactory());
    if (this.statement == null) { throw new EOFException(); }
    this.query = null; // TODO: add toString on SQLStatement
    this.parameterCount = statement.getBindCount();
    this.parameters = Arrays.asList(new Object[statement.getBindCount()]);
    Collections.fill(parameters, BindManager.UNBOUND_PARAMETER);
}
 
Example 14
public PhoenixPreparedStatement(PhoenixConnection connection, String query) throws SQLException {
    super(connection);
    this.query = query;
    this.statement = parseStatement(query);
    this.parameterCount = statement.getBindCount();
    this.parameters = Arrays.asList(new Object[statement.getBindCount()]);
    Collections.fill(parameters, BindManager.UNBOUND_PARAMETER);
}
 
Example 15
Source Project: MyTown2   File: ClientInventoryUpdate.java    License: The Unlicense 5 votes vote down vote up
public void send(EntityPlayer player) {
    if(mode == 1)
        Collections.fill(player.inventoryContainer.inventoryItemStacks, null);
    else if(mode == 2) {
        // Inventory slots: http://hydra-media.cursecdn.com/minecraft.gamepedia.com/8/8c/Items_slot_number.JPG?version=8c2b6c3bebb8855b34f07f232a9e6d6f
        int inventorySlot = player.inventory.currentItem;

        // Container slots: http://wiki.vg/images/1/13/Inventory-slots.png
        int containerSlot = inventorySlot < 9? 36 + inventorySlot : inventorySlot;
        player.inventoryContainer.inventoryItemStacks.set(containerSlot, null);
    }
    player.inventoryContainer.detectAndSendChanges();
}
 
Example 16
public PhoenixPreparedStatement(PhoenixConnection connection, PhoenixStatementParser parser) throws SQLException, IOException {
    super(connection);
    this.statement = parser.nextStatement(new ExecutableNodeFactory());
    if (this.statement == null) { throw new EOFException(); }
    this.query = null; // TODO: add toString on SQLStatement
    this.parameterCount = statement.getBindCount();
    this.parameters = Arrays.asList(new Object[statement.getBindCount()]);
    Collections.fill(parameters, BindManager.UNBOUND_PARAMETER);
}
 
Example 17
public PhoenixPreparedStatement(PhoenixConnection connection, String query) throws SQLException {
    super(connection);
    this.query = query;
    this.statement = parseStatement(query);
    this.parameterCount = statement.getBindCount();
    this.parameters = Arrays.asList(new Object[statement.getBindCount()]);
    Collections.fill(parameters, BindManager.UNBOUND_PARAMETER);
}
 
Example 18
@Override
public void clearParameters() throws SQLException {
    Collections.fill(parameters, BindManager.UNBOUND_PARAMETER);
}
 
Example 19
Source Project: bither-android   File: RawDataDiceView.java    License: Apache License 2.0 4 votes vote down vote up
public void clearData() {
    Collections.fill(data, Dice.One);
}
 
Example 20
public void clearData(){
    Collections.fill(data, Boolean.FALSE);
}