An instance is a specific realization of any object.
Questions tagged [instances]
516 questions
5
votes
5 answers
Creating a new Ord instance for Lists
This is my first attempt at creating a custom instance of a class such as Ord.
I've defined a new data structure to represent a list:
data List a = Empty | Cons a (List a)
deriving (Show, Eq)
Now I want to define a new instance of Ord for List…

cdk
- 6,698
- 24
- 51
5
votes
1 answer
Multiple instances of Google Maps on one page
I have a form that allows you to preview coordinates via a google map. The user can dynamically add multiple sets of coordinates to the form. The amount of coordinates are variable.
I loop through the variables with this code which I feel it has to…

Ratty
- 436
- 1
- 7
- 19
4
votes
5 answers
Java classes and constructors
I hope this won't sound like a stupid question.
I have a class A and a class B. Now the only thing B has is a String ID.
Now I can have multiple objects A that each can have 0 or more objects of type B.
These are contained in a HashMap(ID,someData)…

Fofole
- 3,398
- 8
- 38
- 59
4
votes
1 answer
Why do Ruby instance method invocations behave differently when prefixed with 'self'?
The two invocations of an instance method carry different semantics. The first call to bar works as expected.
class T
def foo
bar # <= This works. "bar" is printed.
self.bar # <= EXCEPTION: `foo': private method `bar' called for ...
…

Sniggerfardimungus
- 11,583
- 10
- 52
- 97
4
votes
2 answers
what does instancing do in webgl
I want to know is any way to understand how many times vertex shader will be called in a draw call in webgl? because I want to know what does instancing realy do, is it call every shared vertices for each instance? so it will call too many time…

mh-alahdadian
- 353
- 5
- 21
4
votes
3 answers
Instantiate and reuse instances of objects in XAML
I want to instantiate objects in XAML, and reuse these instances. I think it should be simple but I'm stuck, I'm probably missing something obvious.
Say I want to add Cats to different Rooms (Room has an ObservableCollection containing objects of…

eriksmith200
- 2,159
- 5
- 22
- 33
4
votes
2 answers
Typeclasses 101: GHC too "eager" to derive instance?
Given the following code:
class C a where
foo :: a -> a
f :: (C a) => a -> a
f = id
p :: (C a) => (a -> a) -> a -> a
p g = foo . g
Now, if I try to invoke p f, GHC complains:
> p f
No instance for (C a0) arising from a use of `p'
In the…

ftl
- 647
- 3
- 13
4
votes
2 answers
How calculate the number of instances in Google App Engine
I aim to create an application that will be deployed thanks to Google App Engine.
Before that I would like to calculate the cost of Google App Engine.
For this I have to provide the Number of instances, per hour. How can caluculate this number of…

Benoit Foussier
- 41
- 1
- 3
4
votes
4 answers
Save different class instances in a list
I have a general Java question.
I've got different 'spell' classes, they aren't made of 1 object because they differ too much.
So I created for example 3 classes:
called Ice ice = new Ice();
called Hurricane hurricane = new Hurricane();
called Bomb…

Wouter
- 125
- 1
- 9
4
votes
1 answer
Will adding an instance of a class to a list copy the instance or just 'reference' it?
allInstancesOfFoo = []
class foo(object):
def __init__(self)
allInstancesOfFoo.append(self)
bar1=foo()
bar2=foo()
bar3=foo()
Will doing this create copies of bars 1-3 and place them in that list, or will it simply add a 'reference' of…

wanabeswordsman
- 43
- 3
4
votes
2 answers
Unique object instances in an array (Ruby)
I have a custom defined class Instruction. Instances are initialized and collected in an array. There are some duplicate (all instance variables identical) instances and I want to filter them out.
class Instruction
attr_accessor :date, :group,…

Adomas Zvirzdinas
- 43
- 1
- 4
4
votes
1 answer
Update calendar instances.end via events.dtend
When I update the CalendarContract.Events DTEND column, why doesn't the change show up in the CalendarContract.Instances END column?
My app allows the user to view and change calendar events using the CalendarContract.Events APIs. The code performs…

Peri Hartman
- 19,314
- 18
- 55
- 101
4
votes
1 answer
Android fragment instances avoid duplicates
Hi I am not sure I am doing the right thing. I have several fragments in one activity (not shown at the same time). When I add the fragment do I have to check if a previous instance exists? I am using the compatibility package and my fragment…

vallllll
- 2,731
- 6
- 43
- 77
4
votes
3 answers
Can I run 1000 AWS micro instances simultaneously?
I have a simple pure C program, that takes an integer as input, runs for a while (let's say an hour) and then returns me a text file. I want to run this program 1000 times with input integers from 1 to 1000.
Currently I'm running this program in…

rgiglio
- 41
- 4
4
votes
4 answers
I need a Python class that keep tracks of how many times it is instantiated
I need a class that works like this:
>>> a=Foo()
>>> b=Foo()
>>> c=Foo()
>>> c.i
3
Here is my try:
class Foo(object):
i = 0
def __init__(self):
Foo.i += 1
It works as required, but I wonder if there is a more pythonic way to do it.

BlogueroConnor
- 1,893
- 4
- 17
- 18