Search Results

Search found 6374 results on 255 pages for 'double underscore'.

Page 185/255 | < Previous Page | 181 182 183 184 185 186 187 188 189 190 191 192  | Next Page >

  • Storing objects in STL vector - minimal set of methods

    - by osgx
    Hello What is "minimal framework" (necessary methods) of object, which I will store in STL <vector>? For my assumptions: #include <vector> #include <cstring> using namespace std; class Doit { private: char *a; public: Doit(){a=(char*)malloc(10);} ~Doit(){free(a);} }; int main(){ vector<Doit> v(10); } gives *** glibc detected *** ./a.out: double free or corruption (fasttop): 0x0804b008 *** Aborted and in valgrind: malloc/free: 2 allocs, 12 frees, 50 bytes allocated.

    Read the article

  • Behaviour of System.Timer when Interval property changed

    - by lowlyintern
    I have a System.Timer setup to trigger an event every day at 2AM. If the process the timer starts fails then I want the timer to be reset to run every 15 minutes until the process completes succesfully. // this is how the timer is set up. // this is working correctly. double startTime = milliseconds_of_hour_to_start. Timer = new System.Timers.Timer( startTime); Here is the code to reset the timer on success or failure of the event handler. NOTE the timer is not being stopped, just the Interval property is being reset. if (ProcessSuccess) { Timer.Interval = TimeSpan.FromHours(24).TotalMilliseconds; } else { Timer.Interval = TimeSpan.FromMinutes(15).TotalMilliseconds; } My question is this, if the process fails say 4 times, then succeeds will the Timer now be running at around 3AM? i.e. after failing will the original start time of 2AM be advanced by 15 minutes?

    Read the article

  • Prevent printing -0

    - by fishinear
    If I do the following in Objective-C: NSString *result = [NSString stringWithFormat:@"%1.1f", -0.01]; It will give result @"-0.0" Does anybody know how I can force a result @"0.0" (without the "-") in this case? EDIT: I tried using NSNumberFormatter, but it has the same issue. The following also produces @"-0.0": double value = -0.01; NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init]; [numberFormatter setNumberStyle:NSNumberFormatterDecimalStyle]; [numberFormatter setMaximumFractionDigits:1]; [numberFormatter setMinimumFractionDigits:1]; NSString *result = [numberFormatter stringFromNumber:[NSNumber numberWithDouble:value]];

    Read the article

  • How can find out the system default currency symbol on BlackBerry?

    - by ageektrapped
    I have a need to display a currency value in my application. There doesn't seem to be an easy way to do this with the RIM API, so I'm reduced to creating my own solution (a common refrain for BlackBerry development, unfortunately) Currently I'm using the Formatter class, from javax.microedition.locale like so protected String formatResult(double result) { try { Locale l = Locale.getDefaultForSystem(); Formatter formatter = new Formatter(l.toString()); return formatter.formatCurrency(result); } catch (UnsupportedLocaleException e) { return "This fails for the default locale because BlackBerry sucks"; } } I always hit the catch block in the simulator. Since this doesn't work by default on the simulator, I'm hesitant to put it in the application. So I have two questions: Can anyone tell me if the above solution is the way to go? And how to fix it, of course. Is there a way I can retrieve the currency symbol for the current locale programmatically so I can format myself?

    Read the article

  • floats in NSArray

    - by JordanC
    I have an NSArray of floats which I did by encapsulating the floats using [NSNumber numberWithFloat:myFloat] ; Then I passed that array somewhere else and I need to pull those floats out of the array and perform basic arithmatic. When I try [myArray objectAtIndex:i] ; The compiler complains that I'm trying to perform arithmatic on a type id. It also won't let me cast to float or double. Any ideas? This seems like it should be an easy problem. Maybe it will come to me after another cup of coffee, but some help would be appreciated. Thanks.

    Read the article

  • Question About Eclipse Java Debugger Conditional Breakpoints Inefficiency

    - by Personman
    I just set a conditional breakpoint in Eclipse's debugger with a mildly inefficient condition by breakpoint standards - checking whether a HashMap's value list (8 elements) contains Double.NaN. This resulted in an extremely noticeable slowdown in performance - after about five minutes, I gave up. Then I copy pasted the condition into an if statement at the exact same line, put a noop in the if, and set a normal breakpoint there. That breakpoint was reached in the expected 20-30 seconds. Is there something special that conditional breakpoints do that is different from this, or is Eclipse's implementation just kinda stupid? It seems like they could fairly easily just do exactly the same thing behind the scenes.

    Read the article

  • Sorting Multidimensional Array with Javascript: Integers

    - by tkm256
    I have a 2D array called "results." Each "row" array in results contains both string and integer values. I'm using this script to sort the array by any "column" on an onclick event: function sort_array(results, column, direction) { var sorted_results = results.sort(value); function value(a,b) { a = a[column]; b = b[column]; return a == b ? 0 : (a < b ? -1*direction : 1*direction) } } This works fine for the columns with strings. But it treats the columns of integers like strings instead of numbers. For example, the values 15, 1000, 200, 97 would be sorted 1000, 15, 200, 97 if "ascending" or 97, 200, 15, 1000 "descending." I've double-checked the typeof the integer values, and the script knows they're numbers. How can I get it to treat them as such?

    Read the article

  • Property hiding and reflection (C#)

    - by tehMick
    Declaring a property in a derived class that matches the name of a property in the base class "hides" it (unless it overrides it with the override keyword). Both the base and derived class properties will be returned by Type.GetProperties() if their types don't match. However, if their types do match, shockingly only the derived class's property is returned. For instance: class A { protected double p; public int P { get { return (int)p; } set { p = value; } } } class B : A { public new int P { get { return (int)p; } set { p = value; } } } class C : B { public new float P { get { return (float)p; } set { p = value; } } } Calling typeof(C).GetProperties() will only return B.P and C.P. Is it possible to call GetProperties() in a way that returns all three? There is almost certainly a way to do it by traversing the inheritance hierarchy, but is there a cleaner solution?

    Read the article

  • Deleting Part of An Array in Java to Free Memory on Heap

    - by kate
    I am implementing a dynamic programming algorithm for the knapsack problem in Java. I declare the array and then initialize its size to be [number of objects][capacity of knapsack]. When my number of objects or my capacity gets too large, I get a memory error because I run out of space on the heap. My questions is: If I delete rows from my double array as I go along, will Java free the memory as I delete? Or does Java reserve that memory space for the size of the array I originally created? If it's the latter, is there a way to manually free the memory in Java? Thanks for your Help!

    Read the article

  • Cancel zoom from dbclick event onmap in google maps version 3

    - by aleka
    I initiallize a map in my application like this: function doLoad() { var parnitha= new google.maps.LatLng(38.155428,23.718739); var myOptions = { zoom:16, mapTypeId: google.maps.MapTypeId.SATELLITE, center: parnitha, disableDefaultUI: true, navigationControl: true, scrollwheel: false, navigationControlOptions: { style: google.maps.NavigationControlStyle.SMALL, position: google.maps.ControlPosition.TOP_LEFT}, } map= new google.maps.Map(document.getElementById("map_canvas"), myOptions); }. With double click on the map, it making zoom and i don't want this, because i want to use dbClick event for other reason.Please help me to remove the default dbClick event on the map. Thanks a lot..

    Read the article

  • Upgrading IIS web sever framework 2.0 to 3.5 considerations

    - by Grant
    Hi, i will be responcible for upgrading an IIS web server from the Microsoft .NET framework v2.0 to v3.5. I am wondering if there is anything special i need to know or any caveats i should be aware of before proceding? The site gets a fair number of hits per day and I will be taking it down and performing the upgrade at an off-peak time. Aside from double clicking the installer is there anything i need to know? Will the server need to be rebooted afterwards, does the installer handle all of the configuration changes? etc.. Thanks.

    Read the article

  • Is it possible for a Grails Domain to have no 'id'?

    - by firnnauriel
    Is it possible to create a table that has no 'id'? For example, this is my domain: class SnbrActVector { int nid String term double weight static mapping = { version false id generator: 'identity' } static constraints = { } } When I run this SQL statement, it fails: insert into snbr_act_vector values (5, 'term', 0.5) I checked the table and 'id' is already set to autoincrement. I'm thinking that another option is to remove the 'id' itself. Or is there another workaround for this? Please assume that it is not an option to change the givent SQL statement.

    Read the article

  • Application wide messaging... without singletons?

    - by StormianRootSolver
    So, I want to go for a more Singleton - less design in the future. However, there seem to be a lot of tasks in an application that can't be done in meaningful way without singletons. I call them "application wide services", but they also fall into the same category as the cross cutting concerns, which I usually fix via AOP. Lets take an example: I want an application wide message queue that dispatches messages to components, every component can subscribe and publish there, it's a very nice multicast thing. The message queue and dispatching system are usually a (rather short) singleton class, which is very easy to implement in, say, C#. You can even use double dispatching and utilize message type metadata and the like, it's all so easy to do, it's almost trivial. However, having singletons is not really "object oriented design" (it introduces global variables) and it makes testing harder. Do you have any ideas? I'm asking this question because I'm willing to learn more about this topic, a LOT more. :-)

    Read the article

  • [C++] Why am I not getting the same values?

    - by xbonez
    I am using Bode's formuala to calculate distance of nth planet from sun dist = (4 + 3*(2^(n-2)))/10 If I calculate the distance this way, I get the right values: dist[2] = ((4 + 3*1)/10.0) ; dist[3] = ((4 + 3*2)/10.0) ; dist[4] = ((4 + 3*4)/10.0) ; But doing it this way, gives me incorrect values: vector double> dist(5); for (unsigned int i = 2; i < 5; i++) { dist[i] = ((4 + 3*(2^(3-2)))/10.0) ; } ` Why so?

    Read the article

  • Java : VolatileImage slower than BufferedImage.

    - by Norswap
    I'm making a game in java and in used BufferedImages to render content to the screen. I had performance issues on low end machines where the game is supposed to run, so I switched to VolatileImage which are normally faster. Except they actually slow the whole thing down. The images are created with GraphicsConfiguration.createCompatibleVolatileImage(...) and are drawn to the screen with Graphics.drawImage(...) (follow link to see which one specifically). They are drawn upon a Canvas using double buffering. Does someone has an idea of what is going wrong here ?

    Read the article

  • [C#] Creating standalone, console (shell) for domain-specific operations

    - by mr.b
    Say that I have a system service, and I want to offer a low-level maintenance access to it. For that purpose, I'd like to create a standalone, console application that somehow connects to server process and lets user type in commands, allow it to use auto-completion and auto-suggestion on single/double TAB press (just like linux bash shell, mysql cli, cmd.exe, and countless others), allow command line editing capabilities (history, cursor keys to move around text..), etc. Now, it's not that much of a problem to create something like that by rolling my own from scratch, handling user input, scanning pressed keys, and doing correct actions. But, why reinvent the wheel? Is there some library/framework that helps with this kind of problems, just like readline library that offers improved command-line editing capabilities under linux? Of course, this new "shell" would respond only to valid, domain-specific commands, and would suggest valid arguments, options, switches... Any ideas? Thanks!

    Read the article

  • StreamSocket to Stream in windows phone 8

    - by Abouzar Nouri
    I am trying to use Bluetooth in WP8 to send an image from my app on a device and show it in my app on another device. The receiver has a StreamSocket object to read the data from it like the code below await _dataReader.LoadAsync(4); uint messageLen = (uint)_dataReader.ReadInt32(); await _dataReader.LoadAsync(messageLen); string imageData _dataReader.ReadString(messageLen); Then I have to save all the received data (image) on the device and then create a Stream object from the stored data to give it to the BitmapSource.SetSource(Stream) function to be able to show this image on my app. var image = new BitmapImage(); image.SetSource(stream); All I want to do is not to skip this double work and directly convert the StreamSocket object (from Bluetooth connection) to a Stream object and make the BitmapSource image. Is there any way to do this?

    Read the article

  • Linq GroupBy - how to specify the grouping key at runtime?

    - by toasteroven
    is there a good way to do a Linq GroupBy where the grouping key is determined at runtime? e.g. I want the grouping key to be built from a user-selected list of fields - can you do this? I know I can do it easily if I convert everything to a table of strings, but I was wondering if there was an elegant or clever way to accomplish this otherwise. class Item { public int A, B; public DateTime D; public double X, Y, Z; } I have a List<Item> called data. I want to do things like retrieve the sum of X grouped by A, or the sums of X, Y, and Z, grouped by A and B. but what fields go into the grouping should be able to be specified at runtime in some way.

    Read the article

  • Overloading assignment operator in C#

    - by Carson Myers
    I know the = operator can't be overloaded, but there must be a way to do what I want here: I'm just creating classes to represent quantitative units, since I'm doing a bit of physics. Apparently I can't just inherit from a primitive, but I want my classes to behave exactly like primitives -- I just want them typed differently. So I'd be able to go, Velocity ms = 0; ms = 17.4; ms += 9.8; etc. I'm not sure how to do this. I figured I'd just write some classes like so: class Power { private Double Value { get; set; } //operator overloads for +, -, /, *, =, etc } But apparently I can't overload the assignment operator. Is there any way I can get this behavior?

    Read the article

  • OnSize() Problem in VC++

    - by Anu
    Hi, In my VC++ MFC applcaiton,i have different views.And in each view,when i maximize it,i changed the size and position to new thing(Normally it fully get maximixed to screen size).But i dont want tht.So in OnSize() i coded like this. void CChildFrame::OnSize(UINT nType, int cx, int cy) { CMDIChildWnd::OnSize(nType, cx, cy); int XBorder = GetSystemMetrics(SM_CXMAXIMIZED); int YBorder = GetSystemMetrics(SM_CYMAXIMIZED); switch (nType) { case SIZE_MAXIMIZED: SetWindowPos(NULL,0,60,XBorder-45,YBorder-60,SWP_NOZORDER ); break; } } But what happened is?When i maximize the view,its get maximized to above mention size only.But in that blue bar,there si no minimize,maximize,close button. When i double click in the blue bar,its get to resumed to previous postion with all buttons. How can i get that?

    Read the article

  • "slash before every quote" problem

    - by Camran
    I have a php page which contains a form. Sometimes this page is submitted to itself (like when pics are uploaded). I wouldn't want users to have to fill in every field again and again, so I use this as a value of a text-input inside the form: value="<?php echo htmlentities(@$_POST['annonsera_headline'],ENT_COMPAT,'UTF-8');?>"> This works, except it adds a "\" sign before every double-quote... For instance writing 19" wheels gives after page is submitted to itself: 19\" wheels And if I don't even use htmlentities then everything after the quotes dissappears. What is the problem here?

    Read the article

  • Calculating the angle between two points

    - by kingrichard2005
    I'm currently developing a simple 2D game for Android. I have a stationary object that's situated in the center of the screen and I'm trying to get that object to rotate and point to the area on the screen that the user touches. I have the constant coordinates that represent the center of the screen and I can get the coordinates of the point that the user taps on. I'm using the formula outlined in this forum: How to get angle between two points? -It says as follows "If you want the the angle between the line defined by these two points and the horizontal axis: double angle = atan2(y2 - y1, x2 - x1) * 180 / PI;". -I implemented this, but I think the fact the I'm working in screen coordinates is causing a miscalculation, since the Y-coordinate is reversed. I'm not sure if this is the right way to go about it, any other thoughts or suggestions are appreciated.

    Read the article

  • How to model localized items

    - by tweir
    I'm currently designing a e-commerce solution. One of the primary requirements is for the store to support localized item details. The same store must be able to support multiple languages via the user's language selection and/or browser preference. I have two tables: Item (id, sku, price, ...) ItemDetails (item_id, language, title, ...) For each Item, there will be multiple rows corresponding to the item, where the (item_id,language) pair will be unique. I would like to model this as: class Item { public string sku; public double price; public ItemDetails Details; } Based on the user's session, I would like the items returned to have the Details object corresponds to the user's selected language (from their session). What are some approaches for representing this?

    Read the article

  • How to debug lost events posted from non-GUI thread in Qt?

    - by gp
    As the subject says, I'm posting events from non-GUI thread (some GStreamer thread, to be precise). Code looks like this: GstBusSyncReply on_bus_message(GstBus* bus, GstMessage* message, gpointer data) { bool ret = QMetaObject::invokeMethod(static_cast<QObject*>(data), "stateChanged", Qt::QueuedConnection); Q_ASSERT(ret); return GST_BUS_PASS; } The problem is, stateChanged (doesn't matter whether it is a slot or signal) is not called. I've stepped into QMetaObject::invokeMethod with debugger, followed it till it called PostMessage (it is Qt 4.6.2 on Windows, by the way) – everything seemed to be OK. Object pointed to by data lives in GUI thread, I've double-checked this. How can I debug this problem? Or, better, maybe sidestep it altogether?

    Read the article

< Previous Page | 181 182 183 184 185 186 187 188 189 190 191 192  | Next Page >