Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a Collection that works like a Dictionary without the values?

I need a collection that works just like a Dictionary/Hashtable in a sense that it will only contain 1 instance of a given object at any time. A generic class would be preferable, but I'll take what I can get. Does this collection live somewhere in the framework?

like image 976
Micah Avatar asked Dec 03 '08 15:12

Micah


People also ask

What is key-value dictionary?

A Python dictionary is a collection of key-value pairs where each key is associated with a value. A value in the key-value pair can be a number, a string, a list, a tuple, or even another dictionary. In fact, you can use a value of any valid type in Python as the value in the key-value pair.

Can a dictionary contain a list as values?

In this program, we will discuss how to create a dictionary of lists. In Python, the dictionary of lists means we have to assign values as a list. In Python dictionary, it is an unordered and immutable data type and can be used as a keys element.

How to create a Python dictionary?

In Python, a dictionary can be created by placing a sequence of elements within curly {} braces, separated by 'comma'. Dictionary holds pairs of values, one being the Key and the other corresponding pair element being its Key:value.

Why can a list not be used as a key for a value in a dictionary?

Because lists are mutable, dict keys need to be hashable, and hashing mutable objects is a bad idea because hash values should be computed on the basis of instance attributes. Example 1: hashing a mutable object where the hash value is based on a mutable characteristic of the object.


1 Answers

HashSet<T> from System.Core.dll

like image 155
Ilya Ryzhenkov Avatar answered Nov 11 '22 00:11

Ilya Ryzhenkov