set

Can set_intersection be used with hash_set in C++?

I am calculating intersection, union and differences of sets. I have a typedef of my set type: typedef set<node_type> node_set; When it is replaced with typedef hash_set<node_type> node_set; The results are different. It's a complicated program, and before I start debugging - am I doing it right? When I use functions like this: s...

Java: Set<E> collection, where items are identified by its class

I need Set collection, where its items will be identified by items class. Something like ReferenceIdentityMap from Appache Collections, but on class scope i.e. two different instances of same class must be identified as same in this collection. You know, it is a violation of equals()/hashCode() identity principle but in occasional use ...

Compass search not working on Lists

Hello, My Compass search does not seem to search inside Java Lists (It searches only the last node in the list) . It works correctly with Sets, but my application needs sorted data. Could some one please tell me what I am doing wrong and how to fix it? Thanks a lot! ...

problem while removing an element from the TreeSet

I am doing the following class RuleObject implements Comparable{ @Override public String toString() { return "RuleObject [colIndex=" + colIndex + ", probability=" + probability + ", rowIndex=" + rowIndex + ", rule=" + rule + "]"; } String rule; double probability; int ro...

How to use java.Set

I'm trying to make it working for quite some time,but just can't seem to get it. I have object Tower built of Block's. I've already made it working using arrays, but I wanted to learn Set's. I'd like to get similar functionality to this: public class Tower { public Tower(){ } public Tower add(Block k1){ //(...) //if block al...

Gorm findAllBy inside gsp doubt

Hi, can anybody tell me why this works <g:each var="n" in="${com.pp.News.list()}"> <h2>${n.t}</h2> <p>${n.tx}</p> </g:each> but this doesn't ? <g:set var="news" value="${com.pp.News.findAllByShow(true,[sort:'prio', order:'desc',max:5])}" /> <g:each var="n" in="news"> <h2>${n.t}</h2> <p>${n.tx}</p> </g:each> Part of the e...

What is a simple C library for a set of integer sets?

I've got to modify a C program and I need to include a set of unsigned integer sets. That is, I have millions of sets of integers (each of these integer sets contains between 3 and 100 integers), and I need to store these in some structure, lets call it the directory, that can in logarithmic time tell me whether a given integer set alre...

[Haskell] Set of an Unordered Data Type with a given ordering

I'm trying to put this data type in a Haskell Set, but I don't want to give it a general instance of Ord. So I want to give the set an ordering on y-coördinate but without instance Ord Vector. Is this possible? data Vector = V { x :: Double , y :: Double } deriving (Eq) ...

Character encoding issues when generating MD5 hash cross-platform

This is a general question about character encoding when using MD5 libraries in various languages. My concern is: suppose I generate an MD5 hash using a native Python string object, like this: message = "hello world" m = md5() m.update(message) Then I take a hex version of that MD5 hash using: m.hexdigest() and send the message & M...

JavaScript implementation of a set data structure

I'm looking for a decent implementation of a set data structure in JavaScript. It should be able to support elements that are plain JavaScript objects. So far I only found Closure Library's structs.Set, but I don't like the fact that it modifies my data. Any ideas? ...

Python: How do sets work

I have a list of objects which I want to turn into a set. My objects contain a few fields that some of which are o.id and o.area. I want two objects to be equal if these two fields are the same. ie: o1==o2 if and only if o1.area==o2.area and o1.id==o2.id. I tried over-writing __eq__ and __cmp__ but I get the error: TypeError: unhashable...

Java creation of new set too slow

I have this program where it have some recursive function similar to this: public static void lambda(HashSet<Integer> s){ if(end(s)){ return; } for(int i=0;i<w;i++){ HashSet<Integer> p = (HashSet) s.clone(); p.addAll(get_next_set()); do_stuff_to(p); lambda(p); } } What I'm doing ...

Vim: Call an ex command (set) from function?

Drawing a blank on this, and google was not helpful. Want to make a function like this: function JakPaste() let tmp = :set paste? if tmp == "paste" set nopaste else set paste endif endfunction map <F2> :call JakPaste()<CR> However this does not work. I have isolated t...

how best do I find the intersection of multiple sets in python?

I have a list of sets: setlist = [s1,s2,s3...] I want s1 ∩ s2 ∩ s3 ... I can write a function to do it by performing a series of pairwise s1.intersection(s2), etc., but is there a recommended, better, or built-in way? ...

How can I ensure that a wxFrame is brought to the foreground?

I have a wxFrame that receives events. Whenever an event comes in, I want the frame to be brought to the foreground. I'm currently using: my_frame->SetFocus(); But that doesn't seem to work for minimized frames. How can I set the frame as the active window and bring it to the front? Alternatively, is there a method that flashes the ...

what is the underlying data structure of a set c++?

I would like to know how a set is implemented in C++. If I were to implement my own set container without using the STL provided container, what would be the best way to go about this task? I understand STL sets are based on the abstract data structure of a binary search tree. So what is the underlying data structure? An array? Also, h...

C++: need indexed set

I need an indexed associative container that operates as follows: initially empty, size=0. when I add a new element to it, it places it at index [size], very similar to a vector's push_back. It increments the size and returns the index of the newly added element. if the element already exists, it returns the index where it occurs. S...

Why doesn't the F# Set implement ISet<T>?

The .NET Framework is adding an ISet<T> interface with the 4.0 release. In the same release, F# is being added as a first-class language. F# provides an immutable Set<'T> class. It would seem logical to me that the immutable set provided would implement the ISet<T> interface, but it doesn't. Does anyone know why? My guess is that they ...

Nested Set - for CMS with two versions (edit / publish) mode

Hi! I'm looking for a solution (PHP/Symfony/Doctrine) for the following problem. I'm creating a table called 'pages'. This table is a nested set. I also want to create a table called 'pages_published' which has ofcourse also a nested set. Once i create a record in table 'pages' at some point i want to publish this to the 'pages_publis...

Resource files for Company-wise Label Values - Implicit calling of Global Resources

We have several companies using one web application. Companies may decide to display different values in Labels. e.g. CompanyA -> ZipCodeCaption = "Zip Code" CompanyB -> ZipCodeCaption = "Pin Code" CompanyA -> USDSymbolCaption = "USD" CompanyB -> USDSymbolCaption = "$" Currently, we have different settings saved for different compa...