Questions tagged [object-identity]

whether two variable are referring to the same object.

Identity is a property of an object that uniquely defines its abstract location.

Two objects stored in variable a and b are said to have the same identity, if a and b actually refer to the same object (same class, same abstract memory location). On can test identity of two objects using

As an implementation detail, identity hints about potential co-location of objects in physical or virtual memory, and thus may be related to performance. In some languages, one can get a value representing the object's identity, or address (although this token is only valid during the object's lifetime):

54 questions
5
votes
1 answer

how to get the objectID from url?

my code is below : NSURL *urlID = [objID URIRepresentation]; NSString *strID = [urlID absoluteString]; NSDictionary *infoDict = [NSDictionary dictionaryWithObjectsAndKeys:strID, @"objectID", nil]; localNotification.userInfo =…
yjw44
  • 257
  • 1
  • 4
  • 10
4
votes
2 answers

Implementing object tracking, like in Boost::Serialization

I'm implementing a "clone" function for a graph of objects in C++ and part of the problem is to ensure that if there are two pointers to the same object, it is not cloned twice. I've done this by keeping a map that keeps the original…
exclipy
  • 1,423
  • 1
  • 15
  • 21
4
votes
2 answers

Please explain the technique used in this code to test Object Equality and Identity

Please explain the technique used in this code to test Object Equality and Identity. Better, if you can supply me any web-link/book-reference for detailed discussion. [Serializable] public abstract class BusinessObject : IBusinessObject where…
user366312
  • 16,949
  • 65
  • 235
  • 452
4
votes
1 answer

Morphia saves new entities instead of update _id

Sorry for very dumb question. I'm using Morphia 1.00. Have some entity: @Entity("Vacancy") public class Vacancy { @Id private ObjectId id; @Version long version; private String title; and some other fields, setter and getters. Trying to save…
vacuum
  • 2,273
  • 3
  • 20
  • 32
4
votes
1 answer

Is it possible to get equivalent of 'memory address' of .net Object?

We are rolling a custom serialisation tool into our project and are coming across a need to uniquely identify each object by a primitive value type that can be used as a synonym of its 'identity'. The value need have no meaning or organisation,…
J Collins
  • 2,106
  • 1
  • 23
  • 30
4
votes
2 answers

When are physically distinct values created in OCaml?

I'm trying to understand what the physical equality operators (Pervasives.(==) and Pervasives.(!=)) mean in OCaml. The language manual says that the expression "" is a "constant", not an "expression": 6.5 Constants constant ::== ...…
Mike Samuel
  • 118,113
  • 30
  • 216
  • 245
3
votes
1 answer

How can i get my object id from a generic update views to use in my form in django 1.1

I m using generic view to update object. I m using form : class VehiPrepaClientForm(ModelForm): class Meta: model = VehiPrepa fields = ('date_dem_prepa','carburant','ty_carburant') def clean(self): cleaned_data =…
laurent
  • 660
  • 2
  • 8
  • 19
3
votes
3 answers

Can I use the == operator to compare Point objects in Java?

While i am solving the questions from the book "cracking the coding interview"... i got a doubt.the question is: Given two squares on a two dimensional plane, find a line that would cut these two squares in half. Solution:Any line that goes…
hareendra reddy
  • 1,542
  • 2
  • 14
  • 17
3
votes
3 answers

Why do some Ruby methods like String#replace mutate copies of variables?

So first off I'm just learning Ruby and coming from a JavaScript background. I have a problem that I can't find an answer to. I have this example: a = 'red' b = a b.replace('blue') b = 'green' print a blue My question is: why is this a thing? I…
Jwookie55
  • 33
  • 3
3
votes
2 answers

String concatenation in Python

Can you describe difference between two ways of string concatenation: simple __add__ operator and %s patterns? I had some investigation in this question and found %s (in form without using parentheses) a little faster. Also another question was…
Roman Bodnarchuk
  • 29,461
  • 12
  • 59
  • 75
3
votes
3 answers

What objects are guaranteed to have different identity?

ORIGINAL QUESTION: (My question applies to Python 3.2+, but I doubt this has changed since Python 2.7.) Suppose I use an expression that we usually expect to create an object. Examples: [1,2,3]; 42; 'abc'; range(10); True; open('readme.txt');…
max
  • 49,282
  • 56
  • 208
  • 355
2
votes
0 answers

Why is Groovy copying objects without prompting and reassigning fields?

This is so bizarre I have no idea how to even properly formulate this question, but hopefully some guru recognises what is going on here and can help me. I am working on a Grails project that is exhibiting a bizarre bug. While marshalling a…
Pepijn Schmitz
  • 2,143
  • 1
  • 17
  • 18
2
votes
1 answer

Use object identities when using QUnit.deepEqual() on an array

Situation is as follows: I want to test a function of mine, which returns an array of objects. The objects have no enumerable properties, but are taken from a common cache/store. In my testcases I now want to test, whether the contents of the…
Sirko
  • 72,589
  • 19
  • 149
  • 183
2
votes
4 answers

Is there a Python equivalent of Java's IdentityHashMap?

I'm walking a data structure and would like to build a dict mapping X->Y, where X is a field in the data structure I'm walking and Y is a field in the data structure I'm building on the fly. X is an unhashable type.
Russ Weeks
  • 363
  • 1
  • 11
1
vote
1 answer

dynamic field name in `pipeline` of lookup where the value of the dynamic field name is determined by a variable set in `let`

user schema: { _id: "OjectId", } interaction schema: { blocker_id: user_id_x blocked: { user_id_y: true, user_id_z: true, etc... } } db.user.aggregate([{ $lookup: { …