primitive-types

Do STL maps initialize primitive types on insert?

I have a std::map like this: map<wstring,int> Scores; It stores names of players and scores. When someone gets a score I would simply do: Scores[wstrPlayerName]++; When there is no element in the map with the key wstrPlayerName it will create one, but does it initialize to zero or null before the increment or is it left undefined? ...

De facto list of primitive types usable in C++

If, for example, you're going to write a variant type class, you will naturally need identification of what type an instance of that class is carrying. I'm wondering if anyone knows of any official or semi-official (de-facto?) reference of all primitive datatypes one would possibly be interested in? Only primitives, and no need for abs...

Compare two arrays of primitives in Java?

I know about Arrays.deepEquals(Object[], Object[]) but this doesn't work for primitive types (due limitations of arrays and autoboxing, see this related post). With that in mind, is this the most efficient approach? boolean byteArrayEquals(byte[] a, byte[] b) { if (a == null && b == null) return true; if (a == null || ...

Arithmetic operator overloading for a generic class in C#

Given a generic class definition like public class ConstrainedNumber<T>: IEquatable<ConstrainedNumber<T>>, IEquatable<T>, IComparable<ConstrainedNumber<T>>, IComparable<T>, IComparable where T:struct, IComparable, IComparable<T>, IEquatable<T>, how can I define arithmetic operators for it? The following does not compile, because the '+'...

Passing primitive type to WCF RESTful service

I've been banging my head against the wall for the past couple of hours, here's what we're trying to do: a method expects a primitive/simple type as the request body. Originally we tried with a boolean, but that didn't work so we tried with string and object. Same thing. Here's the server-side code [OperationContract] [WebInvoke(UriTem...

JAXB Java to XML: How not printing primitive type members when default

Hi guys, First attempt to use this cool site - after searching for 2 hours: So I have a Java Bean that is given (I can only annotate not change) and need to map it to XML using JAXB. I would like primitives types not to be printed when they contain their language default, or a user-defined default. As said I cannot change the java bea...

Objective-C Imports, primitive types with Cygwin

I understand the basic syntax of Objective-C, have installed Cygwin, and want to experiment. However i am unsure of two things: What i would import, and what the primitive type names are. Can someone help me? ...

What are the limitations of primitive character types in D?

I am currently exploring the specification of the Digital Mars D language, and am having a little trouble understanding the complete nature of the primitive character types. The book Learn to Tango With D is similarly vague on the capabilities and limitations of the language in this area. The types are given on the website as: char; ...

Pointers, primitives, and properties in Objective-C classes

I really need some clarification — I have a few questions and I'm all mixed up right now. Here is a simple class interface: #import <UIKit/UIKit.h> @interface Car : NSObject{ NSInteger carID; NSString *carName; } @property (nonatomic, assign) NSInteger carID; @property (nonatomic, copy) NSString * carName; @end Why is carI...

Entity Framework: LINQ to Entities only supports casting Entity Data Model primitive types

I wrote a method to allow for an Expression to be passed in for the orderby clause, but I ran into this problem. Unable to cast the type 'System.DateTime' to type 'System.IComparable'. LINQ to Entities only supports casting Entity Data Model primitive types. Basically the expression is this: Expression<Func<K, IComparable>...

.NET Multithreading - Do I need to synchronise access to a variable of primitive type?

The scenario I have a class with a bool Enabled property, that is used by a loop on another thread to see whether it should stop or not. The idea is that a different thread can set that property to false and stop the other thread running cleanly. The question Should I bother to serialise access to that Enabled property using somethin...

Objective C - NSNumber, NSInteger, ...

What's the difference between NSNumber and NSInteger? Are there more primitives like these that I should know about/use? Is there one for floats? ...

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 ...

How to temporarily replace one primitive type with another when compiling to different targets?

How to easily/quickly replace float's for doubles (for example) for compiling to two different targets using these two particular choices of primitive types? Discussion: I have a large amount of c# code under development that I need to compile to alternatively use float, double or decimals depending on the use case of the target assembl...

Java - int/long, float/double

I understand that "2.5" is automatically a double, and to make it a float, I need to do "2.5F" (or should the F be lowercase?), and that I should use a float, say, if I had a constant that only ever needed 2 decimal spaces (like "0.08F" for Ontario PST tax), but I'm not sure whether "12" is an int or a long, but I know "12L" is a long, b...

Is it possible to write swap method in Java?

Here is the question: write a method that swaps two variables. These two variables should be primitives. It doesn't need to be generic e.g. two int variables. Is there a way?! ...

How to convert an NSString into an NSNumber

Hello, How can I convert an NSString containing a number of any primitive data type (e.g. int, float, char, unsigned int, etc.)? The problem is, I don't know which number type the string will contains at runtime. I have an idea how to do it, but I'm not sure if this works with any type, also unsigned and floating point values: long lo...

Java: Unsigned numbers

Hello, Is there a way in Java to use Unsigned numbers like in (My)SQL? For example: I want to use an 8-bit variable (byte) with a range like: 0 -> 256; instead of -128 -> 127. ...

Why must local variables, including primitives, always be initialized in Java?

Why must local variables, including primitives, always be initialized in Java? Why is the same not applicable in the case of instance variables? ...

Can you extract the value of strings from an IBM PHD java heap dump?

I have a PHD format heap dump from an IBM jvm and I wish to examine the values of some strings. With the Sun JVM's binary hprof dumps this is possible, but I haven't been able to recover this information from an IBM dump. I've tried: Eclipse Memory Analyzer (0.8.0.200906170940) with IBM's DTFJ Portal Heap Dump Reader (1.3.0.2009032416...