objects

c# count number of objects of class type within class method

How can I count the number of objects of a class type within a method of that class? For that matter, how to do it outside of a class without adding the objects to a list? I should have thought of that! Thanks! I'm gonna leave it unanswered for a little while to see if there is a better way, because I agree. I'm just sortv wrapping my h...

Change properties of an unknown object in VB.NET

I have a sub that handles when 14 ComboBoxes have their Index changed. I am able to cast the sender of the event, and obtain properties from there. However, after that, I want to be able to change the properties of the actual sender, rather than the cast one. How would I do this? Current code: Private Sub ComboBoxIndexChange(ByVal send...

Creating X Number of Nameless Objects

Hello, In a lot online judge problems, the format for the input is as follows: first line is the number of test cases. Let's say X. Then X lines after that are the conditions for each test case. In the example below, there are two test cases. Each test case specify the upper and lower bound for which primes should be shown in the outpu...

Defining many-to-many relationships in DDD

Are many-to-many table structures defined as Value Objects in DDD? What if my many-to-many structure has a unique id? Also, what about 1-to-many relationships? For instance, if i have 2 structures Post & Comment with 1-to-many (respectively) wouldn't Comment be a Value Object since it technically cannot exist without a corresponding Pos...

Is there a way to have callable objects in Groovy?

If for example I have a class named A. Can I make an object be callable, just like Python does? For example : def myObject = new A() myObject() and that would call some object method. Can it be done? ...

OOP style question

Right now I'm writing a program that will determine the value of a hand of cards. five in total. i have a cardHand object. I'm planning to write an object that compares two objects together in order to determine which hand has a higher value. the two objects that will be compared are objects that contain the possible hand values (one pai...

How can I assign a property to a jQuery object?

Hi, It is in my understanding that referencing any DOM element in jQuery via the dollar sign (like this: $("#mydiv")), returns an object. I am looking to add an additional property to an object as such: $("#mydiv").myprop = "some value"; but this does not seem to work. I am trying to store a value in this object so I can reference it...

Is there any way to find out the number of objects that gets created?

Is there any way to find out the number of objects that gets created? For example, If I need to find the number of objects that gets created for the below piece of code, how can I get it done? Code: String [][] str = { {new String("A"),new String("B"),new String("C")}, {new String("D"),new String("E")} }; ...

Ruby on Rails : Cannot access an object's attributes in an array

Hello, I am building a site with works and their credits. What I am trying o achieve is to find each work's similar works based on the mutual titles in their credits. I am adding each similar work into an array in a for loop and when I try to access the attributes of these works I get a "nil object when you didn't expect it!" error. I...

AS3: Optimizing Object Memory Size

I have have a class that I wrote, and it seems bigger than it should be. It doesn't extend anything, and has very little going on - or so I thought - but each one is taking up just under 100k100 bytes ( thanks back2dos ). I guess that I don't have a very good understanding of what really affects how much memory an object takes up in AS3...

Object type determined at runtime - Javascript (ExtJS)

Hi All, This may not be possible (or might be dead easy! :) ) so here it is... I want to be able to create objects of a type that is dependant on a variable set, without the need for a big switch statement. I think it is possible in PHP to do something like... $objectType = "myNewClass"; $newObject = new $objectType(); where the $n...

What techniques/strategies do people use for building objects in C (not C++)?

I am especially interested in objects meant to be used from within C, as opposed to implementations of objects that form the core of interpreted languages such as python. ...

AS3 Object Filtering

Ok. so I'm working on an app that retrieves items from a db and builds a gallery. I've done this a ton of times, and it should be simple. I'm running into problems, because in this gallery, I get results from a db that includes both image files, and other files. Let's just say I can't change anything but the flash, so I need to detect i...

Compare object instances for equality by their attributes in Python

What is the best way to compare two instances of some object for equality in Python? I'd like to be able to do something like Example: doc1 = ErrorDocument(path='/folder',title='Page') doc2 = ErrorDocument(path='/folder',title='Page') if doc1 == doc2: # this should be True #do something EDIT: To further clarify the question. I'...

Setting a private attribute which is an array on a PHP class fails

I have a problem while setting a private attribute on a PHP class, my __set() method is being called however when I perform this on an attribute which is an array it performs first my __get() method which renders the ser unusable :/ $this->person['name'] = 'perro'; simply, doesn't work,any idea on this subject ? ...

What does this code do (ever seen an object without a reference variable? how about invoking the object later without the reference variable?)?

EventQueue.invokeLater(new Runnable() { public void run() { ZipTestFrame frame = new ZipTestFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }); ...

shared objects within a struct: between a calling program and library (in c)

Hi, In a separate library, we have a struct with: typedef struct bsmat{ int m; int *n; double **d; } bs; where **d is a array of pointers to double arrays. bs *new_bs(int n, double **d); There are two use cases: (a) The main application allocates multiple double matrices and calls the library to construct the structure. b = new...

How come setting value in one array key is setting in another key?

I have an array of objects with various objects within to hold UI values. I wanted to have a button so that element 0's values are replicated through the whole array. However I noticed that setting one set them all. Here is an example without using any looping: console.log('manual 3: ', lis[3].spacer.divider.type); // prints 'none' lis[...

Javascript objects performance

I am unsure how javascript stores objects, and references them. So, I don't know if my plan will cause bad performance. Any insight would be appreciated. I have many divs on a website, and each has a unique id. I have an object constructor: function box_object(box_id){ this.the_box = document.getElementById(box_id); this.rela...

Looping through all instances of a javascript object

Hi, if I have an object constructor like: function cat(color, sex){ this.color = color; this.sex = sex; } and I make some cats: var fluffball = new cat("blue","male"); var shiznitz = new cat("red","male"); var slothersburger = new cat("green","female"); Is it possible to loop through all the cats I have declared? Somethin...