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...
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 ...
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...
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 (...
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_...
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.
...
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...
... 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...
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...
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...
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...
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...
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...
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...
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...
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?
...
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...
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...
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?
...
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...