private int cartTotal() { int total = 0; for (Item item : items) { total += item.getValue(); } return total; }
public final Object get(Object key, long txnTimestamp) throws CacheException { Item item = (Item) region.get(key); if (item != null && item.isReadable(txnTimestamp)) { return item.getValue(); } return null; }
public String get(String name, String key) { for (Item it : items) { if (name.equals(it.getName()) && key.equals(it.getKey())) { return it.getValue(); } } return null; }
private void addToPropertyGrid(ExplorerGrid grid, Item item) { Object[] cols = new Object[4]; cols[0] = item.getName(); cols[1] = item.getType(); cols[2] = item.getValue(); cols[3] = item.isMutli().toString(); grid.addRow(grid.getRowCount(), cols); }
// Creates an ItemSet with the given Item arraylist. public ItemSet(ArrayList<Item> items) { m_lstItemList = new ArrayList<Item>(); if (items != null && !items.isEmpty()) { for (Item itemNew : items) { // Before adding the new item check if it is already added // TODO Instead of looping try m_lstItemList.contains() for (Item itemCurrent : m_lstItemList) { if (itemCurrent.getValue() == itemNew.getValue()) { continue; // If item is already on the list, skip.. // Throw an exception instead ?? } } m_lstItemList.add(itemNew); } } }
private double degree(int[] example) { double degree; Item item; degree = 1.0; for (int i = 0; i < itemset.size() && degree > 0.0; i++) { item = itemset.get(i); if (item.getValue() != example[item.getVariable()]) degree = 0.0; } return (degree); }
private Item findNext() { while (delegate.hasNext()) { Item item = delegate.next(); if (item.getKey() != null && item.getValue() != null) { // Found one. Back up! delegate.previous(); return item; } } return null; }
public String put(String name, String key, String value) { modified = true; for (Item it : items) { if (name.equals(it.getName()) && key.equals(it.getKey())) { String oldValue = it.getValue(); it.setValue(value); return oldValue; } } items.add(new Item(name, key, value)); return null; }
@Override public String put(String key, String value) { if (key == null || value == null) { throw new NullPointerException(); } Item item = itemIndex.get(key); String result = null; if (item != null) { result = item.getValue(); item.setValue(value); } else { item = new Item(key, value); addItem(item, alphabetize); } return result; }
@Override public View getView(int position, View convertView, ViewGroup parent) { View view = convertView; if (null == view) { LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = layoutInflater.inflate(R.layout.row_layout, parent, false); } final Item data = appsList.get(position); if (null != data) { TextView appName = (TextView) view.findViewById(R.id.key); TextView packageName = (TextView) view.findViewById(R.id.value); Button b = (Button) view.findViewById(R.id.button_remove); b.setTag(position); b.setOnClickListener( new OnClickListener() { @Override public void onClick(final View v) { AccountManager mAccountManager; mAccountManager = AccountManager.get(context); Account account = new Account(data.getValue(), context.getString(R.string.auth_type)); mAccountManager.removeAccount( account, new AccountManagerCallback<Boolean>() { @Override public void run(AccountManagerFuture<Boolean> arg0) { if (arg0.isDone()) Toast.makeText(context, "Removed..." + data.getValue(), Toast.LENGTH_SHORT) .show(); appsList.remove(Integer.parseInt(String.valueOf(v.getTag()))); notifyDataSetChanged(); } }, null); } }); appName.setText(data.getKey()); packageName.setText(data.getValue()); } return view; }
public void save() { if (!modified) { return; } try { PrintWriter out = new PrintWriter(source); for (Item it : items) { out.println(it.getName()); out.println(it.getKey()); out.println(it.getValue()); } out.close(); modified = false; } catch (Exception ex) { ex.printStackTrace(); } }
// Creates an ItemSet with the given integer list. // The number of parameters is indeterminate. public ItemSet(Item... items) { m_lstItemList = new ArrayList<Item>(); // Loop through the sent items and add them to the list if (items != null && items.length > 0) { for (int i = 0; i < items.length; i++) { // Before adding the new item check if it is already added // TODO Instead of looping try m_lstItemList.contains() for (Item itemCurrent : m_lstItemList) { if (itemCurrent.getValue() == items[i].getValue()) { continue; // If item is already on the list, skip.. // Throw an exception instead ?? } } m_lstItemList.add(items[i]); } } }
/** * It adds a rule to the rule base * * @param itemset itemset to be added * @param time Time of the rule */ public void add(Itemset itemset, long time) { int i; Item item; int[] antecedent = new int[n_variables]; for (i = 0; i < n_variables; i++) antecedent[i] = -1; // Don't care for (i = 0; i < itemset.size(); i++) { item = itemset.get(i); antecedent[item.getVariable()] = item.getValue(); } Rule r = new Rule(this.dataBase); r.asignaAntecedente(antecedent); r.setConsequent(itemset.getClas()); r.setConfidence(itemset.getSupportClass() / itemset.getSupport()); r.setSupport(itemset.getSupportClass()); r.setTime(time); this.ruleBase.add(r); }
/** 1行ごとのビューを生成する */ @Override public View getView(int position, View convertView, ViewGroup parent) { View view = convertView; if (convertView == null) { view = _inflater.inflate(R.layout.listrow, null); } // 現在参照しているリストの位置からItemを取得する Item item = this.getItem(position); if (item != null) { // Itemから必要なデータを取り出し、それぞれTextViewにセット String title = item.getTitle(); _title = (TextView) view.findViewById(R.id.rowitem); _title.setText(title); String value = item.getValue(); _value = (TextView) view.findViewById(R.id.rowvalue); _value.setText(value); } return view; }
public void addItem(Item item) { insertItem(item.getItem(), item.getDir(), item.getValue(), item.getClassName()); }
/** * Get the best item in the Humanoid's inventory. * * @return : The item with the highest value in the Humanoid's inventory. If the Humanoid has no * items, an item with no values is returned. */ public Item getBestItem() { Item tempItem; tempItem = new Item("NO_ITEM", 0, 0, false); for (Item i : inventory) if (i.isWeapon()) if (i.getValue() > tempItem.getValue()) tempItem = i; return tempItem; }
public String getValue() { return item.getValue(); }
public String setValue(String value) { String result = item.getValue(); item.setValue(value); return result; }
public void testRefresh() { ExtObjectContainer client1 = openNewSession(); ExtObjectContainer client2 = openNewSession(); Item item1 = retrieveInstance(client1); Item item2 = retrieveInstance(client2); Item next1 = item1; int value = 10; while (next1 != null) { Assert.areEqual(value, next1.getValue()); next1 = next1.next(); value--; } Item next2 = item2; value = 10; while (next2 != null) { Assert.areEqual(value, next2.getValue()); next2 = next2.next(); value--; } item1.setValue(100); item1.next().setValue(200); client1.store(item1, 2); client1.commit(); Assert.areEqual(100, item1.getValue()); Assert.areEqual(200, item1.next().getValue()); Assert.areEqual(10, item2.getValue()); Assert.areEqual(9, item2.next().getValue()); // refresh 0 client2.refresh(item2, 0); Assert.areEqual(10, item2.getValue()); Assert.areEqual(9, item2.next().getValue()); // refresh 1 client2.refresh(item2, 1); Assert.areEqual(100, item2.getValue()); Assert.areEqual(9, item2.next().getValue()); // refresh 2 client2.refresh(item2, 2); Assert.areEqual(100, item2.getValue()); // FIXME: maybe a bug // Assert.areEqual(200, item2.next().getValue()); next1 = item1; value = 1000; while (next1 != null) { next1.setValue(value); next1 = next1.next(); value++; } client1.store(item1, 5); client1.commit(); client2.refresh(item2, 5); next2 = item2; for (int i = 1000; i < 1005; i++) { Assert.areEqual(i, next2.getValue()); next2 = next2.next(); } client1.close(); client2.close(); }
public void addItem(Item item, String optionStyle) { insertItem(item.getItem(), item.getDir(), item.getValue(), optionStyle); }
public TValue find(TKey key) { Item<TKey, TValue> item = itemsHT.get(key); return item == null ? null : item.getValue(); }
private OptionElement createOption(Item item) { return createOption(item.getItem(), item.getDir(), item.getValue(), item.getClassName()); }