Possible Duplicate:
Which collection for storing unique strings?
I am currently using a Dictionary<string, bool> to store a list of unique identifiers. These identifiers do not need to have any data associated with them - I am just using the Dictionary to be able to quickly check for duplicates.
Since I only need keys, and no ...
Hi,
Is there a good way in C# to mimic the following python syntax:
mydict = {}
mydict["bc"] = {}
mydict["bc"]["de"] = "123"; # <-- This line
mydict["te"] = "5"; # <-- While also allowing this line
In other words, I'd like something with [] style access that can return either another dictionary or a string type, depending o...
I would like to write a dictionary. What algorithms/structures should I use?
Each word or phrase has a corresponding description (examples, videos, images, and more). It should be possible to easily add/remove words and modify description. Quick access is more relevant than quick adding/removing. It should be possible to filter words o...
Hello
I have this dictionary in my apps model file:
TYPE_DICT = (
("1", "Shopping list"),
("2", "Gift Wishlist"),
("3", "test list type"),
)
model, which uses this dict is this:
class List(models.Model):
user = models.ForeignKey(User)
name = models.CharField(max_length=200)
type = models.PositiveIntegerFi...
is there a built in function for this or do you need to do a loop here.
...
I've been puzzling over this for a few days... feel free to shoot down any of my assumptions.
We're using a Dictionary with integer keys. I assume that the value of the key in this case is used directly as the hash. Does this mean (if the keys are grouped over a small range) that the distribution of the key hash (same as the key itself,...
I have a class looking like this:
class MyClass {
public int Id;
public Dictionary<int, MyClass[]> ChildValues;
}
when I try to deserialize this class using Json.NET:
MyClass x = return JsonConvert.DeserializeObject<MyClass>(s);
I receive the error Expected a JsonObjectContract or JsonDictionaryContract for type 'System.Co...
I am trying to have some sort of Data Object (I'm thinking a dictionary) to hold a TON of regular expressions as keys, then I need to take a string of text, and match against them to get the actual value from the Dictionary. I need an efficient way to do this for a large set of data.
I am in C# and I'm not sure where to begin.
...
Hi folks,
I'm trying to create a "dictionary" type - ie hash table with a string as a key. Is this possible or wise in Lisp?
I noticed that this works as expected:
> (setq table (make-hash-table))
#<HASH-TABLE :TEST EQL size 0/60 #x91AFA46>
> (setf (gethash 1 table) "one")
"one"
> (gethash 1 table)
"one"
However, the following does ...
I am trying to create a new dict using a list of values of an existing dict as individual keys.
So for example:
dict1 = dict({'a':[1,2,3], 'b':[1,2,3,4], 'c':[1,2]})
and I would like to obtain:
dict2 = dict({1:['a','b','c'], 2:['a','b','c'], 3:['a','b'], 4:['b']})
So far, I've not been able to do this in a very clean way. Any sugg...
I'm adding items to a StringDictionary and it's possible that a duplicate key will come up. This will of course throw an exception.
If the chance of duplicates is very low (ie it will rarely happen), am I better off using a Try Catch block and leaving it unhandled, or should I always do a .ContainsKey check before adding each entry?
I'...
I have code that has a Dictionary defined as:
Dictionary<int, StringBuilder> invoiceDict = new Dictionary<int, StringBuilder>();
Each Value in each KeyValuePair the Dictionary is actually three separate values currently created as follows:
invoiceDict.Add(pdfCount+i, new StringBuilder(invoiceID.Groups[1].ToString() + "|" + extractFi...
Hi All,
I need advice. I have application that imports 10,000 rows containing name & address from a text file into XElements that are subsequently added to a synchronized queue. When the import is complete the app spawns worker threads that process the XElements by deenqueuing them, making a database call, inserting the database output ...
As the title states, how expensive are Python dictionaries to handle? Creation, insertion, updating, deletion, all of it.
Asymptotic time complexities are interesting themselves, but also how they compare to e.g. tuples or normal lists.
...
Say I wanna bind to dictionary that TKey is string with XAML:
<Label DataContext="{MyDictionary}" Content="{Binding Item("OK")}" />
Doesn't work.
How should I do it?
I am talking about the Item("Key")
...
I found http://words.bighugelabs.com/api.php but nothing like this for definitions/dictionary.
Ideally I'd grab a dictionary file and build my own API for this, but this is for a demo and we need something short-term that can be called from within a javascript function.
...
Consider a production planning application with many products. Each product has a list of InventoryControl objects keyed on InventoryControlType. Depending on the algorithm we run for production planning, we need to access to different types of InventoryControl objects for a given product. This works OK. However, today I needed to introd...
I have a situation where I want to create a mapping from a tuple to an integer. In python, I would simply use a tuple (a,b) as the key to a dictionary,
Does Javascript have tuples? I found that (a,b) in javascript as an expression just returns b (the last item). Apparently this is inherited from C.
So, as a workaround, I thought I can...
I have a piece of code that takes several rows from a database and creates a dictionary object which I push into an array.
do while index < rs.RecordCount or (not rs.EOF)
set dict = Server.CreateObject("Scripting.Dictionary")
for each x in rs.fields
temp = x.value
dict.add lcase(x.name), temp
next
set records(index) = ...
I need to define a class with an internal collection object to hold different types of values(such as string, int, float, DateTime, and bool) by a string key. I could use Hashtable since it is not strongly typed collection class, while the Dictionary is used for strongly typed items (I could use object for Dictionary even though).
Here...