set

Basic Question on storing variables c# for use in other classes

Ok guys I basically have a class which takes in 3 strings through the parameter of one of its method signatures. I've then tried to map these 3 strings to global variables as a way to store them. However, when I try to call these global variables from another class after instantiating this class they display as null values. this i...

Whats the best to way convert a set of Java objects to another set of objects?

Basic Java question here from a real newbie. I have a set of Java objects (of class "MyClass") that implement a certain interface (Interface "MyIfc"). I have a set of these objects stored in a private variable in my class that is declared as follows: protected Set<MyClass> stuff = new HashSet<MyClass>(); I need to provide a public m...

I've got a ComboBox that's giving me grief in WPF using the MVVM pattern

Here's my code: <ComboBox Grid.Column="1" Grid.Row="9" ItemsSource="{Binding Path=PriorityEntries}" SelectedItem="{Binding Path=Priority,Mode=TwoWay}"/> The comboBox is bound properly with PriorityEntries, and when i change the value of the comboBox the "set" of the bound property(Priority) is called setting it to what it needs to be....

Python: See if one set contains another entirely?

Is there a fast way to check if one set entirely contains another? Something like: >>>[1, 2, 3].containsAll([2, 1]) True >>>[1, 2, 3].containsAll([3, 5, 9]) False ...

Ruby Inserting Key, Value elements in Hash.

I want to add elements to my Hash lists, which can have more than one value. Here is my code. I don't know how I can solve it! class dictionary def initialize(publisher) @publisher=publisher @list=Hash.new() end def []=(key,value) @list << key unless @list.has_key?(key) @list[key]...

How do I wrap a repeatbale set of elements in jQuery?

In jQuery how would I go about wrapping a repeatable set of elements with a div? For example I have: img h4 p img h4 p img h4 p I need to wrap each img, h4, p set with a div class="container". So it will look like: <div> class="container"> img h4 p </div> <div> class="container"> img h4 p </div> <div> class="container"> img h4 p </div> ...

What is time complexity for find method in a set in c++?

set<int> s; s.insert(1); s.insert(2); ... s.insert(n); I wonder how much time it takes for s.find(k) where k is a number from 1..n? I assume it is log(n). Is it correct? ...

SET game odds simulation (MATLAB)

I have recently found the great card came - SET. Briefly, there are 81 cards with the four features: symbol (oval, squiggle or diamond), color (red, purple or green), number (one, two or three) and shading (solid, striped or open). The task is to locate (from selected 12 cards) a SET of 3 cards, in which each of the four features is eith...

What is the syntax in C# for creating setters and getters?

I'm familiar with this new syntax sugar: public string Name { get; set; } But what if I was the setter of that variable to have some sort of checking. For example, I want to convert the entire string that is supposed to be Set to all lowercases. public string Name { get; set { ???? } } ...

Syntax for finding structs in multisets - C++

I can't seem to figure out the syntax for finding structs in containers. I have a multiset of Event structs. I'm trying to find one of these structs by searching on its key. I get the compiler error commented below. struct Event { public: bool operator < ( const Event & rhs ) const { return ( time < rhs.time ); } bool operat...

Python Sets vs Lists

In Python, which data structure is more efficient/speedy? Assuming that order is not important to me and I would be checking for duplicates anyway, is a Python set slower than a Python list? ...

How do I create a sliding drawer in code?

I'm trying to create a sliding drawer in code, but I don't understand what to do for the AttributeSet part of the constructor. What do I need to do for that? Also, how do I define in code where the slider is going to show up? Thanks, ...

How do I make PHP's Magic __set work like a natural variable?

Basically, what I want to do is create a class called Variables that uses sessions to store everything in it, allowing me to quickly get and store data that needs to be used throughout the entire site without working directly with sessions. Right now, my code looks like this: <?php class Variables { public function ...

[Java] Efficiently finding the intersection of a variable number of sets of strings.

I have a variable number of ArrayList's that I need to find the intersection of. A realistic cap on the number of sets of strings is probably around 35 but could be more. I don't want any code, just ideas on what could be efficient. I have an implementation that I'm about to start coding but want to hear some other ideas. Currently, jus...

C++ Set Erase Entry Question

Hi. I encountered a problem here. I'm using C++ multiset. This is the test file. Score: 3-1 Ben Steven Score: 1-0 Ben Score: 0-0 Score: 1-1 Cole Score: 1-2 Ben I'm using while loop and ifstream (fin1) to read in from the test file above. multiset<string, less<string> > myset; while(!fin1.eof()) { fin1 >> scoreName; if(scoreName...

MVVM,WPF: How to set a item as selected in a combobox

It seems nobody has yet found a way to set the comboboxitem as selected with a SelectedItem="Binding Property". Is the solution to use a IsSelected Property in the ViewModel object within the combobox itemssource ? ...

Can Python's set absence of ordering be considered random order?

Hello people. I'd like to know if the absence of element ordering of the Python's built-in set structure is "random enough". For instance, taking the iterator of a set, can it be considered a shuffled view of its elements? (If it matters, I'm running Python 2.6.5 on a Windows host.) ...

Deleting elements from STL set while iterating [NEW SOLUTION]

I need to go through a set and remove elements that meet a predefined criteria. This is the test code I wrote: #include <set> #include <algorithm> void printElement(int value) { std::cout << value << " "; } int main() { int initNum[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; std::set<int> numbers(initNum, initNum + 10); // ...

Set context property in jaxws request

Hey, I would like to set context attribute for every webservice made by my application. I tried this went I create the port: ((BindingProvider) port).getRequestContext().put("SomeInfo", someInfo); And to retrieve on webservice: HttpServletRequest request = (HttpServletRequest) getMessageContext().get(MessageContext.SERVLET_REQUEST);...

Django: How to override a related sets "add" method?

I am working on a django project and i want to send a signal when something get's added to some models related set, e.g. we have an owner wo has a set of collectables and each time the method owner.collectable_set.add(something) is getting called i want signal like "collectable_added" or something. signals are clear to me, but in which m...