/** * Returns true if the given object is not null, has the precise type * of this bag, and contains the same number of occurrences of all the * same elements. * * @param object the object to test for equality * @return true if that object equals this bag */ public override bool Equals(Object obj) { if (obj == this) { return(true); } if (obj is Bag == false) { return(false); } Bag other = (Bag)obj; if (other.size() != size()) { return(false); } for (java.util.Iterator <Object> it = _map.keySet().iterator(); it.hasNext();) { Object element = it.next(); if (other.getCount(element) != getCount(element)) { return(false); } } return(true); }
public override bool Equals(Object o) { if (!(o is java.util.Map <Object, Object>)) { return(false); } java.util.Map <Object, Object> m = (java.util.Map <Object, Object>)o; java.util.Set <Object> keys = keySet(); if (!keys.equals(m.keySet())) { return(false); } java.util.Iterator <Object> it = keys.iterator(); while (it.hasNext()) { Key key = (Key)it.next(); Object v1 = get(key); Object v2 = m.get(key); if (!(v1 == null?v2 == null:v1.equals(v2))) { return(false); } } return(true); }
//----------------------------------------------------------------------- /** * Returns an array of all of this bag's elements. * * @return an array of all of this bag's elements */ public virtual Object[] toArray() { Object[] result = new Object[size()]; int i = 0; java.util.Iterator <Object> it = map.keySet().iterator(); while (it.hasNext()) { Object current = it.next(); for (int index = getCount(current); index > 0; index--) { result[i++] = current; } } return(result); }
/** * Copies all of the keys and values from the specified map to this map. * Each key must be non-null and a MultiKey object. * * @param mapToCopy to this map * @throws NullPointerException if the mapToCopy or any key within is null * @throws ClassCastException if any key in mapToCopy is not a MultiKey */ public void putAll(java.util.Map <Object, Object> mapToCopy) { for (java.util.Iterator <Object> it = mapToCopy.keySet().iterator(); it.hasNext();) { Object key = it.next(); checkKey(key); } map.putAll(mapToCopy); }
//----------------------------------------------------------------------- /** * Puts all the entries from the specified map into this map. * This operation is <b>not atomic</b> and may have undesired effects. * * @param map the map of entries to add */ public void putAll(java.util.Map <Object, Object> map) { java.util.Iterator <Object> i = map.keySet().iterator(); while (i.hasNext()) { Object key = i.next(); put(key, map.get(key)); } }
public override void putAll(java.util.Map <Object, Object> mapToCopy) { for (java.util.Iterator <Object> it = mapToCopy.keySet().iterator(); it.hasNext();) { if (mapToCopy.containsKey(it.next()) == false) { throw new java.lang.IllegalArgumentException("Cannot put new key/value pair - Map is fixed size"); } } map.putAll(mapToCopy); }
/// <summary> /// Converts a map to Dictionary /// </summary> /// <typeparam name="K">the type of keys maintained by this map</typeparam> /// <typeparam name="V">the type of mapped values</typeparam> /// <param name="map">the map instance</param> /// <returns>Dictionary(of k,v)</k></returns> public static Dictionary <K, V> ToDictionary <K, V>(this java.util.Map map) { var dict = new Dictionary <K, V>(); var iterator = map.keySet().iterator(); while (iterator.hasNext()) { var key = (K)iterator.next(); dict.Add(key, (V)map.get(key)); } return(dict); }
public static Hashtable ToHashtable(java.util.Map map) { if (map == null) { return(null); } Hashtable table = new Hashtable(); java.util.Iterator it = map.keySet().iterator(); while (it.hasNext()) { string key = (string)it.next(); object val = map.get(key); table[key] = val; } return(table); }
/// <summary> /// Converts a map to a datatable /// </summary> /// <param name="map">the map instance</param> /// <returns>system.data.datatable object</returns> public static DataTable ToDataTabe(this java.util.Map map) { var dt = new DataTable(); dt.Columns.Add("id", typeof(string)); dt.Columns.Add("ProjectID", typeof(string)); var iterator = map.keySet().iterator(); while (iterator.hasNext()) { DataRow r = dt.NewRow(); var o = iterator.next(); r["id"] = o; r["ProjectID"] = map.get(o); dt.Rows.Add(r); } return(dt); }
private void aggregateGroupDescs(java.util.Map <string, java.util.List <android.content.pm.PermissionInfo > > map, java.util.Map <string, string> retMap) { if (map == null) { return; } if (retMap == null) { return; } java.util.Set <string> grpNames = map.keySet(); java.util.Iterator <string> grpNamesIter = grpNames.iterator(); while (grpNamesIter.hasNext()) { string grpDesc = null; string grpNameKey = grpNamesIter.next(); java.util.List <android.content.pm.PermissionInfo> grpPermsList = map.get(grpNameKey ); if (grpPermsList == null) { continue; } foreach (android.content.pm.PermissionInfo permInfo in Sharpen.IterableProxy.Create (grpPermsList)) { java.lang.CharSequence permDesc = permInfo.loadLabel(mPm); grpDesc = formatPermissions(grpDesc, permDesc); } // Insert grpDesc into map if (grpDesc != null) { if (localLOGV) { android.util.Log.i(TAG, "Group:" + grpNameKey + " description:" + grpDesc.ToString ()); } retMap.put(grpNameKey, grpDesc.ToString()); } } }
/// <summary> /// Utility method that displays permissions from a map containing group name and /// list of permission descriptions. /// </summary> /// <remarks> /// Utility method that displays permissions from a map containing group name and /// list of permission descriptions. /// </remarks> private void displayPermissions(bool dangerous) { java.util.Map <string, string> permInfoMap = dangerous ? mDangerousMap : mNormalMap; android.widget.LinearLayout permListView = dangerous ? mDangerousList : mNonDangerousList; permListView.removeAllViews(); java.util.Set <string> permInfoStrSet = permInfoMap.keySet(); foreach (string loopPermGrpInfoStr in Sharpen.IterableProxy.Create(permInfoStrSet )) { java.lang.CharSequence grpLabel = getGroupLabel(loopPermGrpInfoStr); //guaranteed that grpLabel wont be null since permissions without groups //will belong to the default group if (localLOGV) { android.util.Log.i(TAG, "Adding view group:" + grpLabel + ", desc:" + permInfoMap .get(loopPermGrpInfoStr)); } permListView.addView(getPermissionItemView(grpLabel, java.lang.CharSequenceProxy.Wrap (permInfoMap.get(loopPermGrpInfoStr)), dangerous)); } }
/** * Starts a new process based on the current state of this process builder. * * @return the new {@code Process} instance. * @throws NullPointerException * if any of the elements of {@link #command()} is {@code null}. * @throws IndexOutOfBoundsException * if {@link #command()} is empty. * @throws SecurityException * if {@link SecurityManager#checkExec(String)} doesn't allow * process creation. * @throws IOException * if an I/O error happens. */ public Process start()//throws IOException { { if (commandJ.isEmpty()) { throw new IndexOutOfBoundsException(); } String[] cmdArray = new String[commandJ.size()]; for (int i = 0; i < cmdArray.Length; i++) { if ((cmdArray[i] = commandJ.get(i)) == null) { throw new NullPointerException(); } } String[] envArray = new String[environmentJ.size()]; int i2 = 0; /* * foreach (Map.Entry<String, String> entry in environmentJ.entrySet()) { * envArray[i2++] = entry.getKey() + "=" + entry.getValue(); //$NON-NLS-1$ * } */ java.util.Iterator <String> it = environmentJ.keySet().iterator(); while (it.hasNext()) { String key = it.next(); String value = environmentJ.get(key); envArray[i2++] = key + "=" + value; } java.lang.Process process = Runtime.getRuntime().exec(cmdArray, envArray, directoryJ); // TODO implement support for redirectErrorStream return(process); }
public java.util.Iterator <Object> iterator() { return(map.keySet().iterator()); }
protected override java.util.Collection <Object> get(java.util.Map <Object, Object> map) { return(map.keySet()); }
/** * Returns all entries. * * <p>Entries will be returned in the same order they appear * within the archive's central directory.</p> * * @return all entries as {@link ZipArchiveEntry} instances */ public java.util.Enumeration <ZipArchiveEntry> getEntries() { return(java.util.Collections <ZipArchiveEntry> .enumeration(entries.keySet())); }
java.util.Iterator <java.lang.Class> getProviderClasses() { return(providers.keySet().iterator()); }
internal java.util.Iterator <java.lang.Class> list() { return(categories.keySet().iterator()); }
/** * Add an additional Map to the composite. * * @param map the Map to be added to the composite * @throws IllegalArgumentException if there is a key collision and there is no * MapMutator set to handle it. */ public void addComposited(java.util.Map <Object, Object> map) {//throws IllegalArgumentException { lock (this) { for (int i = composite.Length - 1; i >= 0; --i) { java.util.Collection <Object> intersect = CollectionUtils.intersection(this.composite[i].keySet(), map.keySet()); if (intersect.size() != 0) { if (this.mutator == null) { throw new java.lang.IllegalArgumentException("Key collision adding Map to CompositeMap"); } else { this.mutator.resolveCollision(this, this.composite[i], map, intersect); } } } java.util.Map <Object, Object>[] temp = new java.util.Map <Object, Object> [this.composite.Length + 1]; java.lang.SystemJ.arraycopy(this.composite, 0, temp, 0, this.composite.Length); temp[temp.Length - 1] = map; this.composite = temp; } }
public virtual java.util.Set <Object> keySet() { return(map.keySet()); }
static internal java.util.Map DeriveStyle(java.util.Map attribs, FontStyle style, bool createNew) { java.util.Map newAttribs; if (createNew) { newAttribs = new java.util.Hashtable(attribs.size()); java.util.Iterator it = attribs.keySet().iterator(); while (it.hasNext()) { object key = it.next(); object value = attribs.get(key); if (value != null) { newAttribs.put(key, value); } } } else { newAttribs = attribs; } //Bold if ((style & FontStyle.Bold) == FontStyle.Bold) { newAttribs.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD); } else { newAttribs.remove(TextAttribute.WEIGHT); } //Italic if ((style & FontStyle.Italic) == FontStyle.Italic) { newAttribs.put(TextAttribute.POSTURE, TextAttribute.POSTURE_OBLIQUE); } else { newAttribs.put(TextAttribute.POSTURE, TextAttribute.POSTURE_REGULAR); } //Underline if ((style & FontStyle.Underline) == FontStyle.Underline) { newAttribs.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON); } else { newAttribs.remove(TextAttribute.UNDERLINE); } //Strikeout if ((style & FontStyle.Strikeout) == FontStyle.Strikeout) { newAttribs.put(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON); } else { newAttribs.remove(TextAttribute.STRIKETHROUGH); } return(newAttribs); }