本文整理汇总了C#中System.Collections.Hashtable.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.Hashtable.Remove方法的具体用法?C# System.Collections.Hashtable.Remove怎么用?C# System.Collections.Hashtable.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Hashtable
的用法示例。
在下文中一共展示了System.Collections.Hashtable.Remove方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TwoSum2
public int[] TwoSum2(int[] nums, int target)
{
int[] re = new int[2] { 0, 0 };
System.Collections.Hashtable ht = new System.Collections.Hashtable();
for (var i = 0; i < nums.Length; i++)
if (ht[nums[i]] != null)
{
if (nums[i] * 2 == target)
{
re[0] = (int)ht[nums[i]];
re[1] = i + 1;
return re;
}
else
ht.Remove(nums[i]);
}
else
ht.Add(nums[i], i + 1);
for (int i = 0; i < nums.Length - 1; i++)
{
if (ht[target- nums[i]] != null)
{
if (nums[i] * 2 == target) continue;
re[0] = i+1;
re[1] = (int)ht[target - nums[i]];
if (re[0] != re[1])
break;
}
}
return re;
}
示例2: ApplyItems
private void ApplyItems (object[] items)
{
view.BeginUpdate ();
try
{
System.Collections.Hashtable oldItems = new System.Collections.Hashtable (items.Length);
foreach (ListViewItem viewItem in view.Items)
{
object key = GetKeyFromItem (viewItem.Tag);
oldItems[key] = viewItem;
}
foreach (object item in items)
{
object key = GetKeyFromItem (item);
if (oldItems.ContainsKey (key))
{
ListViewItem viewItem = oldItems[key] as ListViewItem;
UpdateListViewItem (viewItem, item);
oldItems.Remove (key);
}
else
{
ListViewItem viewItem = new ListViewItem ();
UpdateListViewItem (viewItem, item);
view.Items.Add (viewItem);
}
}
foreach (ListViewItem item in oldItems.Values)
view.Items.Remove (item);
view.Sort ();
}
finally
{
view.EndUpdate ();
}
}
示例3: DoParsing
//.........这里部分代码省略.........
{
((System.Collections.Stack)prefixes[namespaceURI]).Push(prefixName);
if (this.callBackHandler != null)
((IXmlSaxContentHandler)this.callBackHandler).startPrefixMapping(prefixName, reader.Value);
}
}
}
}
}
if (this.callBackHandler != null)
this.callBackHandler.startElement(namespaceURI, localName, name, attributes);
if (Empty)
{
if (this.NamespaceAllowed)
{
if (this.callBackHandler != null)
this.callBackHandler.endElement(namespaceURI, localName, name);
}
else
if (this.callBackHandler != null)
this.callBackHandler.endElement("", "", name);
}
break;
case System.Xml.XmlNodeType.EndElement:
if (this.namespaceAllowed)
{
if (this.callBackHandler != null)
this.callBackHandler.endElement(reader.NamespaceURI, reader.LocalName, reader.Name);
}
else
if (this.callBackHandler != null)
this.callBackHandler.endElement("", "", reader.Name);
if (this.namespaceAllowed && prefixes.ContainsKey(reader.NamespaceURI) && ((System.Collections.Stack)stackNameSpace).Contains(reader.Name))
{
stackNameSpace.Pop();
System.Collections.Stack namespaceStack = (System.Collections.Stack)prefixes[reader.NamespaceURI];
while (namespaceStack.Count > 0)
{
System.String tempString = (System.String)namespaceStack.Pop();
if (this.callBackHandler != null)
((IXmlSaxContentHandler)this.callBackHandler).endPrefixMapping(tempString);
}
prefixes.Remove(reader.NamespaceURI);
}
break;
case System.Xml.XmlNodeType.Text:
if (this.callBackHandler != null)
this.callBackHandler.characters(reader.Value.ToCharArray(), 0, reader.Value.Length);
break;
case System.Xml.XmlNodeType.Whitespace:
if (this.callBackHandler != null)
this.callBackHandler.ignorableWhitespace(reader.Value.ToCharArray(), 0, reader.Value.Length);
break;
case System.Xml.XmlNodeType.ProcessingInstruction:
if (this.callBackHandler != null)
this.callBackHandler.processingInstruction(reader.Name, reader.Value);
break;
case System.Xml.XmlNodeType.Comment:
if (this.lexical != null)
this.lexical.comment(reader.Value.ToCharArray(), 0, reader.Value.Length);
break;
case System.Xml.XmlNodeType.CDATA:
if (this.lexical != null)
{
lexical.startCDATA();
if (this.callBackHandler != null)
this.callBackHandler.characters(this.reader.Value.ToCharArray(), 0, this.reader.Value.ToCharArray().Length);
lexical.endCDATA();
}
break;
case System.Xml.XmlNodeType.DocumentType:
if (this.lexical != null)
{
System.String lname = this.reader.Name;
System.String systemId = null;
if (this.reader.AttributeCount > 0)
systemId = this.reader.GetAttribute(0);
this.lexical.startDTD(lname, null, systemId);
this.lexical.startEntity("[dtd]");
this.lexical.endEntity("[dtd]");
this.lexical.endDTD();
}
break;
}
}
if (this.callBackHandler != null)
this.callBackHandler.endDocument();
}
catch (System.Xml.XmlException e)
{
throw e;
}
}
示例4: ReadResources
protected virtual Holodeck.Resource[] ReadResources(System.IO.StreamReader file)
{
const string Name = "Name: ";
const string Func = "Func: ";
const string Proc = "Proc: ";
const string Time = "Time: ";
const string Retv = "Retv: ";
const string Errc = "Errc: ";
const string Exce = "Exce: ";
Holodeck.Resource resource;
System.Collections.Hashtable resources = new System.Collections.Hashtable (10);
string stream = file.ReadToEnd ();
try {
int begIndex = 0;
int endIndex = 0;
while (true) {
begIndex = stream.IndexOf (Name, endIndex);
endIndex = stream.IndexOf ("\n", begIndex);
begIndex += Name.Length;
resource.Name = stream.Substring (begIndex, endIndex - begIndex - 1);
begIndex = stream.IndexOf (Func, endIndex);
endIndex = stream.IndexOf ("\n", begIndex);
begIndex += Func.Length;
resource.LastFunction = stream.Substring (begIndex, endIndex - begIndex - 1);
begIndex = stream.IndexOf (Proc, endIndex);
endIndex = stream.IndexOf ("\n", begIndex);
begIndex += Proc.Length;
resource.processID = Int64.Parse (stream.Substring (begIndex, endIndex - begIndex - 1));
begIndex = stream.IndexOf (Time, endIndex);
endIndex = stream.IndexOf ("\n", begIndex);
begIndex += Time.Length;
resource.TimeStamp = stream.Substring (begIndex, endIndex - begIndex - 1);
begIndex = stream.IndexOf (Retv, endIndex);
endIndex = stream.IndexOf ("\n", begIndex);
begIndex += Retv.Length;
resource.ReturnValue = stream.Substring (begIndex, endIndex - begIndex - 1);
begIndex = stream.IndexOf (Errc, endIndex);
endIndex = stream.IndexOf ("\n", begIndex);
begIndex += Errc.Length;
resource.ErrorCode = stream.Substring (begIndex, endIndex - begIndex - 1);
begIndex = stream.IndexOf (Exce, endIndex);
endIndex = stream.IndexOf ("\n", begIndex);
begIndex += Exce.Length;
// resource. = stream.Substring (begIndex, endIndex - begIndex - 1);
resource.NumHits = 1;
resource.threadID = 0;
if (resources.Contains (resource.Name)) {
Holodeck.Resource oldResource = (Holodeck.Resource) resources[resource.Name];
resource.NumHits += oldResource.NumHits;
resources.Remove (resource.Name);
}
resources.Add (resource.Name, resource);
}
} catch (Exception) {
}
Holodeck.Resource[] result = new Holodeck.Resource[resources.Count];
System.Collections.IEnumerator iEnum = resources.Values.GetEnumerator ();
int i = 0;
while (iEnum.MoveNext ()) {
result[i] = (Holodeck.Resource) iEnum.Current;
i++;
}
return result;
}
示例5: processPacket
//.........这里部分代码省略.........
canSeeHiddenNames = rankManager.containsRight(_Rank, "fuse_enter_locked_rooms", userID);
foreach (DataRow dRow in dTable.Rows)
{
if (Type == 0)
Navigator.Append(Encoding.encodeVL64(Convert.ToInt32(dRow["id"])) + "I" + Convert.ToString(dRow["name"]) + Convert.ToChar(2) + Encoding.encodeVL64(Convert.ToInt32(dRow["visitors_now"])) + Encoding.encodeVL64(Convert.ToInt32(dRow["visitors_max"])) + Encoding.encodeVL64(cataID) + Convert.ToString(dRow["description"]) + Convert.ToChar(2) + Encoding.encodeVL64(Convert.ToInt32(dRow["id"])) + "H" + Convert.ToString(dRow["ccts"]) + Convert.ToChar(2) + "HI");
else
{
if (Convert.ToInt32(dRow["showname"]) == 0 && canSeeHiddenNames == false)
continue;
else
Navigator.Append(Encoding.encodeVL64(Convert.ToInt32(dRow["id"])) + Convert.ToString(dRow["name"]) + Convert.ToChar(2) + Convert.ToString(dRow["owner"]) + Convert.ToChar(2) + roomManager.getRoomState(Convert.ToInt32(dRow["state"])) + Convert.ToChar(2) + Encoding.encodeVL64(Convert.ToInt32(dRow["visitors_now"])) + Encoding.encodeVL64(Convert.ToInt32(dRow["visitors_max"])) + Convert.ToString(dRow["description"]) + Convert.ToChar(2));
}
}
DataColumn dCol = navigatorManager.getAccesParent(_Rank, cataID);
if (dCol.Table.Rows.Count > 0) // Sub categories
{
StringBuilder sb = new StringBuilder();
List<int> emptyIDs = new List<int>();
foreach (DataRow dRow in dCol.Table.Rows)
{
sb.Append(" OR category = '" + Convert.ToString(dRow[0]) + "'");
emptyIDs.Add(Convert.ToInt32(dRow[0]));
}
dTable = navigatorManager.getGuestroomQuery("SELECT SUM(visitors_now),SUM(visitors_max),category FROM rooms WHERE" + sb.ToString().Substring(3) + " GROUP BY category", false);
foreach (DataRow dRow in dTable.Rows)
{
if (Convert.ToInt32(dRow[1]) > 0 && hideFull == 1 && Convert.ToInt32(dRow[0]) >= Convert.ToInt32(dRow[1]))
continue;
Navigator.Append(Encoding.encodeVL64(Convert.ToInt32(dRow[2])) + "H" + navigatorManager.getName(Convert.ToInt32(dRow[2])) + Convert.ToChar(2) + Encoding.encodeVL64(Convert.ToInt32(dRow[0])) + Encoding.encodeVL64(Convert.ToInt32(dRow[1])) + Encoding.encodeVL64(cataID));
emptyIDs.Remove(Convert.ToInt32(dRow[2]));
}
foreach (int emptyID in emptyIDs)
Navigator.Append(Encoding.encodeVL64(emptyID) + "H" + navigatorManager.getName(emptyID) + Convert.ToChar(2) + "HH" + Encoding.encodeVL64(cataID));
}
sendData(Navigator.ToString());
break;
}
case "BW": // Navigator - request index of categories to place guestroom on
{
StringBuilder Categories = new StringBuilder();
DataTable dTable;
using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient())
{
dTable = dbClient.getTable("SELECT id,name FROM room_categories WHERE type = '2' AND parent > 0 AND access_rank_min <= " + _Rank);
}
foreach (DataRow dRow in dTable.Rows)
Categories.Append(Encoding.encodeVL64(Convert.ToInt32(dRow["id"])) + dRow["name"] + Convert.ToChar(2));
sendData("C]" + Encoding.encodeVL64(dTable.Rows.Count) + Categories.ToString());
break;
}
case "DH": // Navigator - refresh recommended rooms (random guestrooms)
{
sendData("E_" + Encoding.encodeVL64(3) + navigatorManager.getRandomRooms());
break;
}
case "@P": // Navigator - view user's own guestrooms
示例6: setValue
/// <summary> Sets a value of a nominal attribute or string attribute.
/// Creates a fresh list of attribute values before it is set.
///
/// </summary>
/// <param name="index">the value's index
/// </param>
/// <param name="string">the value
/// </param>
/// <exception cref="IllegalArgumentException">if the attribute is not nominal or
/// string.
/// </exception>
//@ requires string != null;
//@ requires isNominal() || isString();
//@ requires 0 <= index && index < m_Values.size();
internal void setValue(int index, System.String string_Renamed)
{
switch (m_Type)
{
case NOMINAL:
case STRING:
m_Values = (FastVector) m_Values.copy();
m_Hashtable = (System.Collections.Hashtable) m_Hashtable.Clone();
System.Object store = string_Renamed;
if (string_Renamed.Length > STRING_COMPRESS_THRESHOLD)
{
try
{
store = string_Renamed;
}
catch (System.Exception ex)
{
System.Console.Error.WriteLine("Couldn't compress string attribute value -" + " storing uncompressed." + " " + ex.ToString());
}
}
m_Hashtable.Remove(m_Values.elementAt(index));
m_Values.setXmlElementAt(store, index);
m_Hashtable.Add(store, (System.Int32) index);
break;
default:
throw new System.ArgumentException("Can only set values for nominal" + " or string attributes!");
}
}