primitive

for loop in objective-c - primitive array

int matrix[3][3] = { {1,2,3}, {1,2,3}, {1,2,3}, } how can i loop over it? basically the length operation is my concern. for (int i=0; XXXXX; i++) { for (int j=0; XXXX; j++) { int value = matrix[i][j]; } } EDIT: is there a dynamic way of getting the array size? something like sizeof() thank you, chris ...

Objective C Boolean Array

I need to utilize an array of booleans in objective-c. I've got it mostly set up, but the compiler throws a warning at the following statement: [updated_users replaceObjectAtIndex:index withObject:YES]; This is, I'm sure, because YES is simply not an object; it's a primitive. Regardless, I need to do this, and would greatly appreciate...

What is the use of passing const references to primitive types?

In a project I maintain, I see a lot of code like this for simple get/set methods const int & MyClass::getFoo() { return m_foo; } void MyClass::setFoo(const int & foo) { m_foo = foo; } What is the point in doing that instead of the following? int MyClass::getFoo() { return m_foo; } // Removed 'const' and '&' void MyClass::setFoo(...

Comparing Character, Integer and similar types in Java: Use equals or ==?

I wanted to make sure about something in Java: If I have a Character or an Integer or a Long and those sort of things, should I use equals or is == sufficient? I know that with strings there are no guarantees that there is only one instance of each unique string, but I'm not sure about other boxed types. My intuition is to use equals, ...

Is there ever a good time to use int32 instead of sint32 in Google Protocol Buffers?

I've been reading up on Google Protocol Buffers recently, which allows for a variety of scalar value types to be used in messages. According to their documentation, there's three types of variable-length integer primitives - int32, uint32, and sint32. In their documentation, they note that int32 is "Inefficient for encoding negative nu...

OpenGL primitives too dark when multitexturing?

I'm having a problem getting accurate primitive colours when I'm using multi-texturing elsewhere in the scene. Basically, I have some lines and polygons that I am trying render over a video texture (I'm using 3 stage multitexturing to create the video texture)... Anyhow, I know the problem is not alpha related... In fact, I know that in ...

Primitive vs Abstraction when designing library API

In this video after approx 35 minutes Krzysztof Cwalina (Micrsoft's .NET Framework Program Manager) talks about distinguishing library, abstraction and primitive types in their design process. Examples of each: Library types are at top layer: Diagnostic.Debug, EventLog Primitive types are at bottom, have minimal interface and suppose...

Custom primitives in C#?

Apart from the questionable usefulness of this, I'd like to ask if it is possible to do something along these lines. class MyPrimitive { String value; public String Value { get { return value; } set { this.value = value; } } } // Instead of doing this... MyPrimitive a = new MyPrimitive();...

How do I test if a primitive in Objective-C is nil?

I'm doing a check in an iPhone application - int var; if (var != nil) It works, but in X-Code this is generating a warning "comparison between pointer and integer." How do I fix it? I come from the Java world, where I'm pretty sure the above statement would fail on compliation. ...

Keeping a pair of primitives in a Java HashMap

I have a list of files. I would like to scan through and keep a count of the number of files with the same size. the issue is with filesize which is a long, as we know, hashmap will take in only an object and not a primitive. So using new Long(filesize), i put it into the hashmap. instead of getting a pair of (filesize, count), i got a l...

Declaring, Properties, Synthesizing, and Implementing int[] array in Objective C

How do you declare, set properties, synthesize, and implement an int array of size 5 in Objective C? I'm writing this code for an iphone app. Thanks. ...

What is the third boolean state in java?

While I know that by definition a boolean consists of only two states, true or false. I was wondering what value does a boolean have before it is initialized with one of these states. ...

Is there any difference between these two statements?

float ff = 1.2f; Float fo = new Float(1.2f); double fg = 3.2d; Double fh = new Double(2.1d); Can I use '=' between the (1) and (3) or between the (2) and (4)?? ...

Dynamic primitive type property setting in Objective C

I am trying to write a library so that it is generic enough that its useful. The problem is that it needs to update properties of other classes, both the property and class should be dynamic. Now I can do it using public variables no problem, I just pass a pointer to the variable I want to update. However it would also be incredibly use...

Java: proper way to get the class of a primitive array for reflection

I'm trying to use reflection to call a method that takes in a byte array. I'm starting off doing: Class myClass = anObject.getClass(); Class[] parameterTypes = {byte[].getClass();}; But that doesn't work (class expected, } expected) on the byte[] line. Anyone know what I should do? Cast to an Object and declare that the method tak...

Inconsistent behavior on java's ==

Consider this code: class test { public static void main(String[] args) { test inst_test = new test(); int i1 = 2000; int i2 = 2000; int i3 = 2; int i4 = 2; Integer Ithree = new Integer(2); // 1 Integer Ifour = new Integer(2); // 2 System.out.println( Ithree == Ifour ); inst_test....

Java Vector or ArrayList for Primitives

Is there an expandable array class in the Java API equivalent to the Vector or ArrayList class that can be used with primitives (int, char, double, etc)? I need a quick, expandable array for integers and it seems wasteful to have to wrap them in the Integer class in order to use them with Vector or ArrayList. My google-fu is failing ...

Most basic transformed vertex-drawing with Direct3D

I'm absolutely new to DirectX and I'd like to draw some untransformed primitives with the most basic Direct3D configuration (for learning purposes). I already drew some primitives with transformed vertices, that is vertices with the D3DFVF_XYZRHW flag set. Now I'm trying to get the same output with untransformed vertices, but I don't ge...

Cross-platform primitive data types in C++

Unlike Java or C#, primitive data types in C++ can vary in size depending on the platform. For example, int is not guaranteed to be a 32-bit integer. Various compiler environments define data types such as uint32 or dword for this purpose, but there seems to be no standard include file for fixed-size data types. What is the recommended...

ServletWebServer or WebServer ?

What is the advantage of using org.apache.xmlrpc.webserver.ServletWebServer instead of or.apache.xmlrpc.webserver.WebServer when working with XMLRPC in JAVA? Can I use functions that return array of primitives types or nulls with ServletWebServer? ...