set

Problems with const set&. Compiler/STL bug or non-portable usage?

Are there any language lawyers in the house? Should the following code compile? include <set> bool fn( const std::set<int>& rSet ) { if ( rSet.find( 42 ) != rSet.end() ) return true; return false; } On one of the platforms (Sun Workshop) this does not compile. It reports that the find function returned an iterator and the end fu...

how can I get a std::set of keys to a std::map

I was writing an algorithm this morning and I ran into a curious situation. I have two std::maps. I want to perform a set intersection on the sets of the keys of each (to find which keys are common to both maps). At some point in the future, I think it's likely I'll also want to perform set subtraction here as well. Luckily, the STL ...

Fetching a MySQL SET column as a list of integer offsets

I have a table in a MySQL database defined similar to the following: CREATE TABLE doc_types ( id INT UNSIGNED PRIMARY KEY, types SET('foo','bar','baz','quux',...) NOT NULL ) I would like to get the value of the types column as a comma-separated list of 1-based integer offsets into that list of set values, e.g. "1,3,4" for a...

c# - How to iterate through classes fields and set properties

I am not sure if this is possible but I want to iterate through a class and set a field member property without referring to the field object explicitly: public class Employee { public Person _person = new Person(); public void DynamicallySetPersonProperty() { MemberInfo[] members = this.GetType().GetMembers(); foreach (...

MySQL set storing

I have a couple of tables in a web application I'm coding in PHP, and I would like to know if this would be good pratice. CREATE TABLE `products`( `product_id` int NOT NULL auto_increment, `name` varchar(255) NOT NULL, `variations` varchar(255) default NULL, PRIMARY KEY (`product_id`) ) CREATE TABLE `variations`( `variation_...

Updating Nested Set

I was hoping someone could explain how one goes about updating a nested set. I've looked at http://dev.mysql.com/tech-resources/articles/hierarchical-data.html, but it really only deals with adding and deleting nodes. I need to be able to move nodes with and without child nodes. Any help would be appreciated. ...

Django models - how to filter out duplicate values by PK after the fact?

I build a list of Django model objects by making several queries. Then I want to remove any duplicates, (all of these objects are of the same type with an auto_increment int PK), but I can't use set() because they aren't hashable. Is there a quick and easy way to do this? I'm considering using a dict instead of a list with the id as th...

Ruby: Want a Set-like object which preserves order

... or alternatively an Array which prevents duplicate entries. Is there some kind of object in Ruby which: responds to [], []= and << silently drops duplicate entries is Enumerable (or at least supports find_all) preserves the order in which entries were inserted ? As far as I can tell, an Array supports points 1, 3 and 4; while a Se...

Dataset visualizer does not appear - VS 2005

I cannot see the magnifying glass when I hover my mouse over a DS.I have already tried all the steps in : http://stackoverflow.com/questions/239206/datatable-visualizer-disappeared-from-my-visual-studio/ and it seems I still do not see the visualizer in my VS2005! ANY help would be appreciated with regards to uninstalling /reinstalling...

Using Python set type to implement ACL

Currently I have tables like: Pages, Groups, GroupPage, Users, UserGroup. With pickled sets I can implement the same thing with only 3 tables: Pages, Groups, Users. set seems a natural choice for implementing ACL, as group and permission related operations can be expressed very naturally with sets. If I store the allow/deny lists as pic...

Which method does Set.removeAll() use underneath: equals or compareTo?

Consider the code: class A { private int i; boolean equals( Object t) { if (this == t) return true; if (!( t instanceof A)) return false; if (this.i == t.i); } } Map<String,A> orig; Map<String,B> dup; I am trying to do this orig.entrySet().removeAll(dup.entrySet()); I see that the equ...

getting or setting cookies with javascript

Hello, My question is if I can set a cookie using javascript (and read it) My first impression is that the code beneath doesn't work If I look in my vista cookie folder, I can not the name off the cookie function zetCookie(naam,waarde,dagen) { if (dagen) { var date = new Date(); date.setTime(date.getTime()+(day...

Using NHibernate and not referencing its assembly in the client application

Hi, We have a multi-tiered application using CSLA Business Objects and NHibernate ORM. In our Business Objects, we hold our collection data members as ICollection<T>, and in our object mapping files we define them as <set>s. Since NHibernate uses its own concrete types to fetch these collections, we have a problem when these collection...

Optimized implementations of java.util.Map and java.util.Set?

I am writing an application where memory, and to a lesser extent speed, are vital. I have found from profiling that I spend a great deal of time in Map and Set operations. While I look at ways to call these methods less, I am wondering whether anyone out there has written, or come across, implementations that significantly improve on acc...

PersistentSet in ZODB 3

ZODB provides a PersistentList and a PersistentMapping, but I'd like a PersistentSet. I wrote a quick class that mirrors the ancient PersistentList from ZODB 2. Because there's no UserSet in Python, I had to extend from the C-based built-in set. class PersistentSet(UserSet, Persistent): def __iand__(self, other): set.__iand__(other...

Set= log.txt in batch

I have like a log.txt file which contains: MyName My batch: @echo off set name= [log.txt] in the [log.txt] part, it should read 'MyName' from the log.txt file, to set it as 'name'. How? ...

Create possible pairs irrespective of order in a indefinite set of values.

What i am trying to figure out is an algorithm that will create possible pairs irrespective of order in a indefinite set of values. for example let's say the set is A,B,C,D,E then possible sets are AB AC AD AE BC CD DE but... i also want pairs of more than 2 values. for example ABC ABD ABE BCD BCE but also ABCD or ABCE. The proble...

CMD For Loop does not hold set /a value

Didn't know how to explain this well, so here is the code @echo off set test=0 for /f %%a in (textfile.txt) do ( rem loops five times(5 lines in textfile.txt) set /a test=test+1 rem Adds 1 to Test echo %%a rem Echo's correct line in file echo %test% rem Echo's whatever X was before the loop ) echo %test% rem Displays the correct v...

is there any wayout to set init parameter in servletconfig or servletContext object?

if i want to modify init-parameter value in any of ServletContext or ServletConfig. any want it to be updated after servlet is destroyed by container. is there any wayout? ...

Why have HashSet but not Set in C#?

Old question My understanding is that C# has in some sense HashSet and set types. I understand what HashSet is. But why set is a separate word? Why not every set is HashSet<Object>? New question Why does C# has no generic Set type, similar to Dictionary type? From my point of view, I would like to have a set with standard lookup/addit...