Java Code Examples for java.util.ArrayList.add()

The following are Jave code examples for showing how to use add() of the java.util.ArrayList class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: metanome-algorithms   File: DVHyperLogLogAlgorithm.java   View Source Code Vote up 6 votes
public void execute() throws AlgorithmExecutionException{
	////////////////////////////////////////////
	// THE DISCOVERY ALGORITHM LIVES HERE :-) //
	////////////////////////////////////////////
	

input = this.inputGenerator.generateNewCopy();
   this.relationName = input.relationName();
   this.columnNames = input.columnNames();
   ArrayList<HyperLogLog> Columns = new ArrayList<HyperLogLog>();
   for (int i = 0; i < columnNames.size(); i++)
     Columns.add(new HyperLogLog(eps));
    
   while (input.hasNext()) {
     List<String> CurrentTuple=input.next();
     for (int i = 0; i < columnNames.size(); i++)
     
          Columns.get(i).offer(CurrentTuple.get(i));

	
}
 
   for (int i = 0; i < columnNames.size(); i++)
   {addStatistic(NUMBEROFDISTINCT, Columns.get(i).cardinality(), columnNames.get(i), relationName); }
   
}
 
Example 2
Project: spring2017java   File: ArrayListDemoSection4.java   View Source Code Vote up 6 votes
public ArrayListDemoSection4() {
    int x[] = new int[4];
    x[0] = 30;
    x[1] = 87;
    x[2] = 89;
    x[3] = 33;
    for (int i = 0; i < x.length; i++)
        System.out.println(x[i]);
    
    ArrayList<Integer> numbersList = new ArrayList<>();
    numbersList.add(30);
    numbersList.add(87);
    numbersList.add(89);
    for (int i = 0; i < numbersList.size(); i++)
        System.out.println(numbersList.get(i));
    
    // enhanced for loop
    for (Integer num : numbersList)
        System.out.println(num);
}
 
Example 3
Project: AOSP-Kayboard-7.1.2   File: AdditionalSubtypeUtils.java   View Source Code Vote up 6 votes
/**
 * Returns the extra value that is optimized for the running OS.
 * <p>
 * Historically the extra value has been used as the last resort to annotate various kinds of
 * attributes. Some of these attributes are valid only on some platform versions. Thus we cannot
 * assume that the extra values stored in a persistent storage are always valid. We need to
 * regenerate the extra value on the fly instead.
 * </p>
 * @param localeString the locale string (e.g., "en_US").
 * @param keyboardLayoutSetName the keyboard layout set name (e.g., "dvorak").
 * @param isAsciiCapable true when ASCII characters are supported with this layout.
 * @param isEmojiCapable true when Unicode Emoji characters are supported with this layout.
 * @return extra value that is optimized for the running OS.
 * @see #getPlatformVersionIndependentSubtypeId(String, String)
 */
private static String getPlatformVersionDependentExtraValue(final String localeString,
        final String keyboardLayoutSetName, final boolean isAsciiCapable,
        final boolean isEmojiCapable) {
    final ArrayList<String> extraValueItems = new ArrayList<>();
    extraValueItems.add(KEYBOARD_LAYOUT_SET + "=" + keyboardLayoutSetName);
    if (isAsciiCapable) {
        extraValueItems.add(ASCII_CAPABLE);
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN &&
            SubtypeLocaleUtils.isExceptionalLocale(localeString)) {
        extraValueItems.add(UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME + "=" +
                SubtypeLocaleUtils.getKeyboardLayoutSetDisplayName(keyboardLayoutSetName));
    }
    if (isEmojiCapable && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        extraValueItems.add(EMOJI_CAPABLE);
    }
    extraValueItems.add(IS_ADDITIONAL_SUBTYPE);
    return TextUtils.join(",", extraValueItems);
}
 
Example 4
Project: SO_reputation   File: Main.java   View Source Code Vote up 6 votes
private static void setInputList(ArrayList<String> inputList)
  {
  	String[] id_data = null;
  	String line;
  	Scanner scan = new Scanner(System.in);
System.out.println("Enter UserId and a Date (yyyy-mm-dd) separated by a space!");
System.out.println("Enter -1 as UserId to stop");
do
{
	try
	{
		line = scan.nextLine();
		id_data = line.split(" ");
		Integer.parseInt(id_data[0]);
		if (!id_data[0].equals("-1") && isValideDate(id_data[1]))
			inputList.add(line);
		
	}
	catch(NumberFormatException e)
	{
		
	}
}while(!id_data[0].equals("-1"));
scan.close();
  }
 
Example 5
Project: Rescue-Victims   File: Playground.java   View Source Code Vote up 6 votes
/**
 * whether this action can remove at least one possible position
 * the basic idea is the same as the howThisActionCanDistinguish method
 * @param thePool, the possible position pool
 * @param action, the imaged next step (0F,1B,2L,3R)
 * @return double value, the number of different scenario after this action/the total number of
 * scenarios after this action
 */
private boolean canThisActionDistinguish(HashSet<Position> thePool, int action) {
    HashSet<Position> pool = (HashSet<Position>) thePool.clone();
    // if action is not valid, return -1
    ArrayList<String> results = new ArrayList<String>();
    for (Position pos : pool) {
        // clone the position (if we use the original one, we need to move
        // it back, which I don't want to do)
        Position copy = pos.clone();
        // simulate the movement
        copy.relativeMove(action);
        results.add(getRelativeOccupiedInfo(copy));
    }
    double diffNum = new HashSet<String>(results).size();
    return diffNum > 1;
}
 
Example 6
Project: JAddOn   File: JUtils.java   View Source Code Vote up 6 votes
public static ArrayList<File> getFilesOfNames(String[] names, ArrayList<File> files) {
    ArrayList<File> ausgabe = new ArrayList<>();
    for(File f : files) {
        boolean temp = false;
        for(String g : names) {
            if(g.equals(f.getName())) {
                temp = true;
                break;
            }
        }
        if(temp) {
            ausgabe.add(f);
        }
    }
    return ausgabe;
}
 
Example 7
Project: Hello-Music-droid   File: ArtistMusicFragment.java   View Source Code Vote up 5 votes
private void setUpSongs() {
    songsRecyclerview.setLayoutManager(new LinearLayoutManager(getActivity()));

    ArrayList<Song> songList;
    songList = ArtistSongLoader.getSongsForArtist(getActivity(), artistID);

    // adding one dummy song to top of arraylist
    //there will be albums header at this position in recyclerview
    songList.add(0, new Song(-1, -1, -1, "dummy", "dummy", "dummy", -1, -1));

    mSongAdapter = new ArtistSongAdapter(getActivity(), songList, artistID);
    songsRecyclerview.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST));
    songsRecyclerview.setAdapter(mSongAdapter);
}
 
Example 8
Project: myfaces-trinidad   File: NavigationTreeBean.java   View Source Code Vote up 5 votes
public TreeDataDemo() {
    TreeNodeBean matt = _createNode("Matt", "male");
    TreeNodeBean john = _createNode("John", "male");
    TreeNodeBean ira = _createNode("Ira", "female");
    TreeNodeBean tom = _createNode("Tom", "male");
    TreeNodeBean jack = _createNode("Jack", "male");
    TreeNodeBean victoria = _createNode("Victoria", "female");
    TreeNodeBean angelina = _createNode("Angelina", "female");
    TreeNodeBean mark = _createNode("Mark", "male");
    TreeNodeBean kate = _createNode("Kate", "female");
    TreeNodeBean lucy = _createNode("Lucy", "female");
    TreeNodeBean amy = _createNode("Amy", "female");
    TreeNodeBean victor = _createNode("Victor", "male");

    root.add(matt);

    ArrayList<TreeNodeBean> list_0 = new ArrayList<TreeNodeBean>();
    list_0.add(john);
    list_0.add(victoria);
    list_0.add(kate);
    list_0.add(lucy);
    list_0.add(amy);
    list_0.add(victor);
    matt.setChildren(list_0);

    ArrayList<TreeNodeBean> list_0_0 = new ArrayList<TreeNodeBean>();
    list_0_0.add(ira);
    list_0_0.add(jack);
    john.setChildren(list_0_0);
    ArrayList<TreeNodeBean> list_0_0_0 = new ArrayList<TreeNodeBean>();
    list_0_0_0.add(tom);
    ira.setChildren(list_0_0_0);

    ArrayList<TreeNodeBean> list_0_1 = new ArrayList<TreeNodeBean>();
    list_0_1.add(angelina);
    list_0_1.add(mark);
    victoria.setChildren(list_0_1);
}
 
Example 9
Project: Progetto-I   File: LetturaOggetti.java   View Source Code Vote up 5 votes
/**
 * subLetturaOggetti() prende quello che gli passa il metodo lettura()
 * e li scrive negli attributi di un oggetto, e poi aggiunge quell'oggetto ad un
 * ArrayList.
 * 
 * @param st
 * @param oggetti
 */
public void subLetturaOggetti(StringTokenizer st, ArrayList oggetti)
{
    String nome = st.nextToken();
    String attributo = st.nextToken();
    String fileDomande = percorsoFile + st.nextToken();
    String fileScelte = percorsoFile + st.nextToken();
    String fileAdiacenze = percorsoFile + st.nextToken();

    Oggetto o = new Oggetto(nome, attributo, fileDomande, fileScelte, fileAdiacenze);
    oggetti.add(o);
}
 
Example 10
Project: ctsms   File: AspDaoImpl.java   View Source Code Vote up 5 votes
private ArrayList<AspSubstanceVO> toAspSubstanceVOCollection(Collection<AspSubstance> substances) { // lazyload persistentset prevention
	// related to http://forum.andromda.org/viewtopic.php?t=4288
	AspSubstanceDao aspSubstanceDao = this.getAspSubstanceDao();
	ArrayList<AspSubstanceVO> result = new ArrayList<AspSubstanceVO>(substances.size());
	Iterator<AspSubstance> it = substances.iterator();
	while (it.hasNext()) {
		result.add(aspSubstanceDao.toAspSubstanceVO(it.next()));
	}
	Collections.sort(result, SUBSTANCE_ID_COMPARATOR);
	return result;
}
 
Example 11
Project: Neural-Network-Programming-with-Java-SecondEdition   File: NeuralOutputData.java   View Source Code Vote up 5 votes
public ArrayList<Double> getTargetColumnArrayList(int i){
    ArrayList<Double> result = new ArrayList<>();
    for(int j=0;j<numberOfRecords;j++){
        result.add(targetData.get(j).get(i));
    }
    return result;
}
 
Example 12
Project: metanome-algorithms   File: Ducc.java   View Source Code Vote up 5 votes
@Override
 public ArrayList<ConfigurationRequirement<?>> getConfigurationRequirements() {
   ArrayList<ConfigurationRequirement<?>> spec = new ArrayList<>();
   ConfigurationRequirementRelationalInput input = new ConfigurationRequirementRelationalInput(INPUT_HANDLE);
   spec.add(input);

   ConfigurationRequirementBoolean nullEqualsNull = new ConfigurationRequirementBoolean(NULL_EQUALS_NULL);
   Boolean[] defaultNullEqualsNull = new Boolean[1];
   defaultNullEqualsNull[0] = true;
nullEqualsNull.setDefaultValues(defaultNullEqualsNull);
   nullEqualsNull.setRequired(true);
   spec.add(nullEqualsNull);
   
   return spec;
 }
 
Example 13
Project: java-chess   File: Pawn.java   View Source Code Vote up 5 votes
/**
 * @param b Board
 * @param x x location of piece
 * @param y y location of piece
 * @return
 */
public ArrayList<Move> getMoves(Board b, int x, int y) {
	ArrayList<Move> moves = new ArrayList<Move>();
	
	if(color == Piece.WHITE) {
		// forward
		if(valid(x,y+1) && !b.getTile(x, y+1).isOccupied())
			moves.add(new Move(x,y,x,y+1));
		
		// kill diagonally
		if(valid(x+1,y+1) && b.getTile(x+1, y+1).isOccupied() && b.getTile(x+1, y+1).getPiece().getColor() != color)
			moves.add(new Move(x,y,x+1,y+1));
		
		// kill diagonally
		if(valid(x-1,y+1) && b.getTile(x-1, y+1).isOccupied() && b.getTile(x-1, y+1).getPiece().getColor() != color)
			moves.add(new Move(x,y,x-1,y+1));
	}
	else {
		// forward
		if(valid(x,y-1) && !b.getTile(x, y-1).isOccupied())
			moves.add(new Move(x,y,x,y-1));
		
		// kill diagonally
		if(valid(x+1,y-1) && b.getTile(x+1, y-1).isOccupied() && b.getTile(x+1, y-1).getPiece().getColor() != color)
			moves.add(new Move(x,y,x+1,y-1));
		
		// kill diagonally
		if(valid(x-1,y-1) && b.getTile(x-1, y-1).isOccupied() && b.getTile(x-1, y-1).getPiece().getColor() != color)
			moves.add(new Move(x,y,x-1,y-1));
	}
	
	return moves;
}
 
Example 14
Project: Mujeed-Arabic-Prolog   File: Factory.java   View Source Code Vote up 5 votes
public Symbol[] registered() throws InternalError {
ArrayList<Symbol> s = new ArrayList<Symbol>();

for (String objectName : this.list) {
    //objectName = "sdc." + objectName;
    s.add(this.createInstance(objectName));
}

return s.toArray(new Symbol[this.list.size()]);
   }
 
Example 15
Project: Locked   File: MerchantManager.java   View Source Code Vote up 5 votes
public static ArrayList<Location> getAllNPCsLocations() {
    ArrayList<Location> locations = new ArrayList<>();
    for (String npc : getAllNPCs()) {
        locations.add(getLocation(npc));
    }
    return locations;
}
 
Example 16
Project: mycat-src-1.6.1-RELEASE   File: MycatConfig.java   View Source Code Vote up 5 votes
public String[] getDataNodeSchemasOfDataHost(String dataHost) {
	ArrayList<String> schemas = new ArrayList<String>(30);
	for (PhysicalDBNode dn: dataNodes.values()) {
		if (dn.getDbPool().getHostName().equals(dataHost)) {
			schemas.add(dn.getDatabase());
		}
	}
	return schemas.toArray(new String[schemas.size()]);
}
 
Example 17
Project: EARLGREY   File: ModelCore.java   View Source Code Vote up 5 votes
public ArrayList<ModelCore> get(int init,int limit){
	int limite = 0;
	ArrayList<ModelCore> retorno = new ArrayList<ModelCore>();
	try {
		while(this.set.next() && (limite++ < (init+limit) || limit == -1)){
			if(limite <= init) continue;
			Enumeration<String> keys = fields.keys();
			ModelCore m = (ModelCore) model.newInstance();
			while(keys.hasMoreElements()){
				String llave = keys.nextElement();
				Field campo = fields.get(llave);
				if(campo.getType().equals(int.class) || campo.getType().equals(Integer.class)){
					campo.set(m, set.getInt(llave));
				}
				else if(campo.getType().equals(float.class) || campo.getType().equals(Float.class)){
					campo.set(m, set.getFloat(llave));
				}
				else if(campo.getType().equals(double.class) || campo.getType().equals(Double.class)){
					campo.set(m, set.getDouble(llave));
				}
				else if(campo.getType().equals(String.class)){
					campo.set(m, set.getString(llave));
				}
				else if(campo.getType().equals(GEOM.class)){
					campo.set(m, new GEOM(set.getString(llave)));
				}
				else if(campo.getType().equals(CENTROID.class)){
					campo.set(m, new CENTROID(set.getString(llave)));
				}
			}
			retorno.add(m);
		}
	} catch (SQLException | InstantiationException | IllegalAccessException e) {
		// TODO Auto-generated catch block
		conector.close();
		e.printStackTrace();
	}
	this.conector.close();
	return retorno;
}
 
Example 18
Project: boohee_v5.6   File: MarketingHelper.java   View Source Code Vote up 5 votes
public ArrayList<String> checkAllSorted(ArrayList<String> arrayList) {
    ArrayList<String> arrayList2 = new ArrayList();
    ArrayList checkAll = checkAll();
    if (arrayList == null || checkAll == null) {
        return arrayList2;
    }
    Iterator it = arrayList.iterator();
    while (it.hasNext()) {
        String str = (String) it.next();
        if (checkAll.contains(str)) {
            arrayList2.add(str);
        }
    }
    return arrayList2;
}
 
Example 19
Project: brModelo   File: Texto.java   View Source Code Vote up 4 votes
@Override
public ArrayList<InspectorProperty> GenerateProperty() {
    ArrayList<InspectorProperty> res = super.GenerateProperty();

    InspectorProperty tmp = InspectorProperty.FindByProperty(res, "setTexto");
    tmp.ReSetCaptionFromConfig("texto");
    tmp.tipo = InspectorProperty.TipoDeProperty.tpTextoLongo;
    
    res.add(res.indexOf(tmp), InspectorProperty.PropertyFactoryTexto("texto.titulo", "setTitulo", getTitulo()));
    res.add(res.indexOf(tmp), InspectorProperty.PropertyFactorySN("texto.painttitulo", "setPaintTitulo", isPaintTitulo()));
    
    res.add(InspectorProperty.PropertyFactoryMenu("texto.alinhamento", "setAlinhamentoByInt", getAlinhamento().ordinal(), Editor.fromConfiguracao.getLstTextoAlin()));
    res.add(InspectorProperty.PropertyFactorySN("texto.alinhamento.v", "setCentrarVertical", isCentrarVertical()));
    
    res.add(InspectorProperty.PropertyFactoryNumero("diagrama.detalhe.alfa", "SetAlfa", (int) (100 * getAlfa())));

    InspectorProperty txtTipo = InspectorProperty.PropertyFactoryMenu("texto.tipo", "setTipobyInt", getTipo().ordinal(), Editor.fromConfiguracao.getLstTipoTexto());
    res.add(txtTipo);

    res.add(InspectorProperty.PropertyFactoryCor("texto.bkcolor", "setBackColor", getBackColor()));
    
    tmp = InspectorProperty.FindByProperty(res, "setForeColor");
    tmp.ReSetCaptionFromConfig("texto.forecolor");
    
    res.add(InspectorProperty.PropertyFactorySN("texto.sombra", "setSombra", isSombra()).AddCondicaoForTrue(new String[] {"setCorSombra"}));
    
    res.add(InspectorProperty.PropertyFactoryCor("texto.sombra.cor", "setCorSombra", getCorSombra()));

    res.add(InspectorProperty.PropertyFactorySN("texto.autosize", "setAutosize", isAutosize()));
            
    res.add(InspectorProperty.PropertyFactorySeparador("texto.gradiente"));
    
    String[] grupo = new String[]{"setGradienteStartColor", "setGradienteEndColor",
        "setGDirecao"
    };
    res.add(InspectorProperty.PropertyFactorySN("texto.gradiente.is", "setGradiente", isGradiente()).AddCondicaoForTrue(grupo)
            .AddCondicaoForTrue(new String[]{"setGradientePinteDetalhe", "setGradienteCorDetalhe"})
            .AddCondicaoForFalse(new String[]{"setBackColor"})
    );
    res.add(InspectorProperty.PropertyFactoryCor("texto.gradiente.startcor", "setGradienteStartColor", getGradienteStartColor()));
    res.add(InspectorProperty.PropertyFactoryCor("texto.gradiente.endcor", "setGradienteEndColor", getGradienteEndColor()));
    res.add(InspectorProperty.PropertyFactorySN("texto.gradiente.detalhe", "setGradientePinteDetalhe", isGradientePinteDetalhe()).AddCondicaoForTrue(new String[]{"setGradienteCorDetalhe"}));
    res.add(InspectorProperty.PropertyFactoryCor("texto.gradiente.detalhecor", "setGradienteCorDetalhe", getGradienteCorDetalhe()));
    res.add(InspectorProperty.PropertyFactoryMenu("texto.gradiente.direcao", "setGDirecao", getGDirecao(), Editor.fromConfiguracao.getLstDirecao(Controler.Comandos.cmdTexto)));
    res.add(InspectorProperty.PropertyFactoryNumero("diagrama.detalhe.alfa", "SetAlfa", (int) (100 * getAlfa())));
    ArrayList<String> ngrp = new ArrayList<>(Arrays.asList(grupo));
    ngrp.add("setGradiente");
    ngrp.add("SetAlfa");
    ngrp.add("setBackColor");

    txtTipo.AddCondicao(new String[]{"2", "3"}, new String[]{"setGradientePinteDetalhe", "setGradienteCorDetalhe", "setCorSombra", "setSombra"
    });
    txtTipo.AddCondicao(new String[]{"1", "2", "3"}, ngrp.toArray(new String[]{}));
    txtTipo.AddCondicao(new String[]{"0"}, new String[]{"setAutosize"});

    tmp = InspectorProperty.FindByProperty(res, "setTextoAdicional");
    res.remove(tmp);

    res.add(InspectorProperty.PropertyFactorySeparador("texto.atreladoalinha"));
    if (LinhaMestre != null) {
       res.add(InspectorProperty.PropertyFactorySN("texto.movimentacaomanual", "setMovimentacaoManual", isMovimentacaoManual()));
    } 
    ArrayList<SuperLinha> lins = getListaDeLinhas();
    if (lins.size() > 0) {
        int a = lins.indexOf(getLinhaMestre());
        ArrayList<String> tbls = getStrListaDeLinhas(lins);
        tbls.add(0, Editor.fromConfiguracao.getValor("Inspector.obj.selecione"));
        res.add(InspectorProperty.PropertyFactoryMenu("texto.linhamestre", "SetLinhaMestreInt", a + 1, tbls));
    } else {
        res.add(InspectorProperty.PropertyFactoryApenasLeituraTexto("texto.linhamestre", ""));
    }
    return res;
}
 
Example 20
Project: Progetto-C   File: FontData.java   View Source Code Vote up 4 votes
/**
 * Process a directory potentially full of fonts
 * 
 * @param dir The directory of fonts to process
 * @param fonts The fonts list to add to
 */
private static void processFontDirectory(File dir, ArrayList fonts) {
	if (!dir.exists()) {
		return;
	}
	if (processed.contains(dir)) {
		return;
	}
	processed.add(dir);
	
	File[] sources = dir.listFiles();
	if (sources == null) {
		return;
	}
	
	for (int j=0;j<sources.length;j++) {
		File source = sources[j];
	
		if (source.getName().equals(".")) {
			continue;
		}
		if (source.getName().equals("..")) {
			continue;
		}
		if (source.isDirectory()) {
			processFontDirectory(source, fonts);
			continue;
		}
		if (source.getName().toLowerCase().endsWith(".ttf")) {
			try {
				if (statusListener != null) {
					statusListener.updateStatus("Processing "+source.getName());
				}
				FontData data = new FontData(new FileInputStream(source), 1);
				fonts.add(data);
				
				String famName = data.getFamilyName();
				if (!families.contains(famName)) {
					families.add(famName);
				}
				
				boolean bo = data.getJavaFont().isBold();
				boolean it = data.getJavaFont().isItalic();
				
				if ((bo) && (it)) {
					bolditalic.put(famName, data);
				} else if (bo) {
					bold.put(famName, data);
				} else if (it) {
					italic.put(famName, data);
				} else {
					plain.put(famName, data);
				}
			} catch (Exception e) {
				if (DEBUG) {
					System.err.println("Unable to process: "+source.getAbsolutePath()+" ("+e.getClass()+": "+e.getMessage()+")");
				}
				if (statusListener != null) {
					statusListener.updateStatus("Unable to process: "+source.getName());
				}
			}
		}
	}	
}