Search Results

Search found 331 results on 14 pages for 'mutable'.

Page 9/14 | < Previous Page | 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • Scala: working around the "illegal cyclic reference"

    - by Paul Milovanov
    Hi all, I'm trying to implement a HashMap-based tree that'd support O(1) subtree lookup for a given root key. To that goal, I'm trying to do the following: scala> type Q = HashMap[Char, Q] <console>:6: error: illegal cyclic reference involving type Q type Q = HashMap[Char, Q] ^ So the question is, is there a way for me to do something of the sort without resorting to the ugly HashMap[Char, Any] with subsequent casting of values to HashMap[Char, Any]? Now, I also see that I can use something like the following to avoid the cyclic-reference error, and it might even be cleaner -- but it'd be nice to find out how to correctly do it the first way, just for the educational value. import collections.mutable.HashMap class LTree { val children = new HashMap[Char, LTree] } Thanks a bunch.

    Read the article

  • Nullable Integer ? (working with linq)

    - by nCdy
    I've got exception about convert NULL to Int32. I've got a table from database with nullable tinyint [Column(Storage="_StatType", DbType="tinyint NULL")] public StatType : int { get { _StatType; } } (to get C# code just replace variable's type) and after making linq select def StartLinq = linq <#from lpi in _CfgListParIzm where lpi.ID_ListParIzm==drr1 select (lpi.StatType) #> ; StartLinq.ToArray()[0] can't be readed if that is null :-/ mutable STT : int = 0; try { _=int.TryParse(StartLinq.ToArray()[0].ToString(), out STT); } catch { | _ is Exception => () /* I don't care*/ } upper code is very poor trick :( I wont use it.

    Read the article

  • Android OpenGl Renderer finish event

    - by Eu Vid
    In OpenGL Renderer onDrawFrame is called several time, until the page is completely rendered. I cannot find an event that my page is completeley rendered in order to take a snapshot of the OpenGL page and animate it. I have the solution to take snapshot on at the animation trigger (specific button), but this will imply a specific delay, until Bitmap is created, such as i would like to keep in memory a mutable copy of every page. Do you know other way to animate GLSurfaceView with rendered content? Snippet for triggering snapshot. glSurfaceView.queueEvent(new Runnable() { @Override public void run() { glSurfaceView.getRenderer().takeGlSnapshot(); } }); EGLContext for passing the GL11 object. public void takeGlSnapshot() { EGL10 egl = (EGL10) EGLContext.getEGL(); GL11 gl = (GL11) egl.eglGetCurrentContext().getGL(); takeSnapshot(gl); } onDrawFrame(Gl10 gl) { //is last call for this page event ????????????

    Read the article

  • How is ImmutableObjectAttribute used?

    - by Thomas Levesque
    I was looking for a built-in attribute to specify that a type is immutable, and I found only System.ComponentModel.ImmutableObjectAttribute. Using Reflector, I checked where it was used, and it seems that the only public class that uses it is System.Drawing.Image... WTF? It could have been used on string, int or any of the primitive types, but Image is definitely not immutable, there are plenty of ways to alter its internal state (using a Graphics or the Bitmap.SetPixel method for instance). So the only class in the BCL that is explicitly declared as immutable, is mutable! Or am I missing something?

    Read the article

  • What is a good motivating example for dataflow concurrency?

    - by Alex Miller
    I understand the basics of dataflow programming and have encountered it a bit in Clojure APIs, talks from Jonas Boner, GPars in Groovy, etc. I know it's prevalent in languages like Io (although I have not studied Io). What I am missing is a compelling reason to care about dataflow as a paradigm when building a concurrent program. Why would I use a dataflow model instead of a mutable state+threads+locks model (common in Java, C++, etc) or an actor model (common in Erlang or Scala) or something else? In particular, while I know of library support in the languages above (and Scala and Ruby), I don't know of a single program or library that is a poster child user of this model. Who is using it? Why do they find it better than the other models I mentioned?

    Read the article

  • NSMutableArray withObject(UIImageView *)

    - by pureman
    I am trying to load an NSMutableArray with UIImageViews. Everything is going fine with that. Unfortunately, I have no idea how to use the objects when they are in the mutable array. Here is some code: UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; NSMutableArray *array = [NSMutableArray new]; [array loadWithObject:(UIImageView *)imageView]; [imageView release]; That kind of sets up what I've done. Here's what I want to do: [array objectAtIndex:5].center = GCRectMake(0, 0); but that doesn't work. How can I do this??

    Read the article

  • git rebase branch with all subbranches

    - by knittl
    is it possible to rebase a branch with all it's subbranches in git? i often use branches as quick/mutable tags to mark certain commits. * master * * featureA-finished * * origin/master now i want to rebase -i master onto origin/master, to change/reword the commit featureA-finished^ after git rebase -i --onto origin/master origin/master master, i basically want the history to be: * master * * featureA-finished * (changed/reworded) * origin/master but what i get is: * master * * (same changeset as featureA-finished) * (changed/reworded) | * featureA-finished |.* (original commit i wanted to edit) * origin/master is there a way around it, or am i stuck with recreating the branches on the new rebased commits?

    Read the article

  • When is a scala partial function not a partial function?

    - by Fred Haslam
    While creating a map of String to partial functions I ran into unexpected behavior. When I create a partial function as a map element it works fine. When I allocate to a val it invokes instead. Trying to invoke the check generates an error. Is this expected? Am I doing something dumb? Comment out the check() to see the invocation. I am using scala 2.7.7 def PartialFunctionProblem() = { def dream()() = { println("~Dream~"); new Exception().printStackTrace() } val map = scala.collection.mutable.HashMap[String,()=>Unit]() map("dream") = dream() // partial function map("dream")() // invokes as expected val check = dream() // unexpected invocation check() // error: check of type Unit does not take parameters }

    Read the article

  • iPhone: How to create dynamic image dragging ala iphone icon rearranging

    - by Jim Coffman
    On the iPhone, if you touch and hold your finger on an icon, it starts vibrating, then you can drag them around while the other icons move aside and rearrange dynamically. I'm trying to figure out how to do this inside an application with a grid of images or buttons. I don't need them to vibrate, but I do want the UI to allow the user to drag them with real-time dynamic reordering and then return the new position (ie, an int for accessing a mutable array). Any ideas how to do this? Any sample code out there? Thanks!

    Read the article

  • Immutability of big objects

    - by Malax
    Hi StackOverflow! I have some big (more than 3 fields) Objects which can and should be immutable. Every time I run into that case i tend to create constructor abominations with long parameter lists. It doesn't feel right, is hard to use and readability suffers. It is even worse if the fields are some sort of collection type like lists. A simple addSibling(S s) would ease the object creation so much but renders the object mutable. What do you guys use in such cases? I'm on Scala and Java, but i think the problem is language agnostic as long as the language is object oriented. Solutions I can think of: "Constructor abominations with long parameter lists" The Builder Pattern Thanks for your input!

    Read the article

  • Is NSDictionary key order guaranteed the same as initialized if it never changes?

    - by Thaurin
    I've run into the same problem as found in this question. However, I have a follow-up question. I seem to be in the same situation as the original asker: I have a plist with a hierarchy of dictionaries that define a configuration screen. These are not mutable and will stay the same throughout the application. Since the original discussion seems to focus on problems arising from mutating the dictionary, I must ask for comfirmation: is the order of a dictionary guaranteed the same as they are in the plist, i.e. as it is read (with initWithContentsOfFile)? Can I use allKeys on it in this case to get a correct-order array of keys if the dictionary never changes?

    Read the article

  • Copy NSArray and replace text items with bool values

    - by Frank Martin
    I utilize a (nested) plist to populate UITableViews where users can select entries at the deepest levels and set a checkmark (or not). I want to save these selections in a same structured list where at the deepest level the NSArray contains bool values instead the text strings that are displayed in the UITableView. So how can i build from a hierarchy like the following: Root - Item 0 (Dictionary) - Group (Dictionary) - Items (NSArray) - Item 0: @"Please check me" (String) a hierarchy like this? Root - Item 0 (Dictionary) - Group (Dictionary) - Items (NSArray) - Item 0: 0 (NSNumber) // NSNumber for bool values I'm trying to create a deep mutable copy and replace the items at the deepest levels but have somehow the feeling that this can be done easier. Thanks for any help with this in advance. Frank

    Read the article

  • Does "Value Restriction" mean that there is no higher order functional programming?

    - by Sadache
    Does "Value Restriction" mean that there is no higher order functional programming? I have a problem that each time I try to do a bit of HOP I get caught by a VR error. Example: let simple (s:string)= fun rq->1 let oops= simple "" type 'a SimpleType= F of (int ->'a-> 'a) let get a = F(fun req -> id) let oops2= get "" and I would like to know whether it is a problem of a prticular implementation of VR or it is a general problem that has no solution in a mutable type-infered language that doesn't include mutation in the type system.

    Read the article

  • Ant var and property scope

    - by bobtheowl2
    I have a main build script that calls various targets. One of these targets needs to store a value and another target needs to display it. Obviously this is not working so I think it may be related to scope. I've tried var, property, and declaring the property outside of target1. Since var seems to be mutable, it looks like I need to use it instead, but each time my output is empty. Main script <antcall target="target1"/> <antcall target="display"/> In target1: <var name="myVar" value="${anotherVar}"/> In display: <echo>${myVar}</echo>

    Read the article

  • Autorelease for CGMutablePathRef?

    - by huggie
    Hi, I am developing for iphone. I want to creating a mutable path via CGPathCreateMutable(), and I want to return it out of the function which creates it. I'm suppose to call a CGPathRelease() when I'm done with it. But since I'm returning it I wish to autorelease it. Since Quartz path is a C code (and doesn't look like an objective C object), is it correct that I cannot call autorelease on it? Edit: For others who stumble upon this question, the below advise is for C functions returning Core foundation objects only. For objective C methods returning Core foundation objects, see http://stackoverflow.com/questions/2901942/ownership-regarding-to-returned-quartz-objects

    Read the article

  • Implementing a multimap in Swift with Arrays and Dictionaries

    - by stuffy
    I'm trying to implement a basic multimap in Swift. Here's a relevant (non-functioning) snippet: class Multimap<K: Hashable, V> { var _dict = Dictionary<K, V[]>() func put(key: K, value: V) { if let existingValues = self._dict[key] { existingValues += value } else { self._dict[key] = [value] } } } However, I'm getting an error on the existingValues += value line: Could not find an overload for '+=' that accepts the supplied arguments This seems to imply that the value type T[] is defined as an immutable array, but I can't find any way to explicitly declare it as mutable. Is this possible in Swift?

    Read the article

  • Ref to map vs. map to refs vs. multiple refs

    - by mikera
    I'm working on a GUI application in Swing+Clojure that requires various mutable pieces of data (e.g. scroll position, user data, filename, selected tool options etc.). I can see at least three different ways of handling this set of data: Create a ref to a map of all the data: (def data (ref { :filename "filename.xml" :scroll [0 0] })) Create a map of refs to the individual data elements: (def datamap { :filename (ref "filename.xml") :scroll (ref [0 0]) })) Create a separate ref for each in the namespace: (def scroll (ref [0 0])) (def filename (ref "filename.xml")) Note: This data will be accessed concurrently, e.g. by background processing threads or the Swing event handling thread. However there probably isn't a need for consistent transactional updates of multiple elements. What would be your recommended approach and why?

    Read the article

  • Second level cache for entities with where clause

    - by bertolami
    I am wondering where the hibernate second level cache works as expected if I put a where clause in the hbm.xml class definition: <hibernate-mapping> <class name="com.clazzes.A" table="TABLE_A" mutable="false" where="xyz=5" > <cache usage="read-only"/> <id name="id" /> ... Will hibernate still put the id as key into the cache, or do I have enable the query cache? E.g. when I then execute a HQL query like from A where id=2 that results in an SQL similar to select * from TABLE_A where id=2 and (xyz=5). If I execute this query twice, will it consider the second level cache, or will it nevertheless execute the SQL twice?

    Read the article

  • How to access objects of app Delegate into RootViewController

    - by Ashutosh
    I have a navigation based app in which i am calling a web service. I have done all the work which is required in the background to absorb the web services. The only thing left is to display it in a Table view. The data i want to display is stored in a Mutable array and i can see the data in console and this is in app delegate. I just want to pass this data somehow to root so that i can display it in table view. Could somebody help me with this.

    Read the article

  • Custom iPad keyboard backspace method last character crash

    - by isaaclimdc
    I'm making a custom UI iPad keyboard app, and I'm doing something similar to this post for the backspace method: custom backspace button crashes iPhone app However, the app will always crash when I "backspace" for the last character in the UITextView. I know -substringToIndex won't work for an empty string, but I tried using a temporary mutable string then using -deleteCharactersInRange, and that crashed it too. I'm guessing the crash is due to me manually setting the -selectedRange property for the text view after deleting a character? But even if I do: textView.selectedRange = NSMakeRange(0, 0); the app will crash. Any ideas?

    Read the article

  • What are "named tuples" in Python?

    - by Denilson Sá
    Reading the changes in Python 3.1, I found something... unexpected: The sys.version_info tuple is now a named tuple: I never heard about named tuples before, and I thought elements could either be indexed by numbers (like in tuples and lists) or by keys (like in dicts). I never expected they could be indexed both ways. Thus, my questions are: What are named tuples? How to use them? Why/when should I use named tuples instead of normal tuples? Why/when should I use normal tuples instead of named tuples? Is there any kind of "named list" (a mutable version of the named tuple)?

    Read the article

  • Dynamic name of NSMutableDictionary?

    - by Bruno
    Hi everyone I load from a txt file many info, and I would like, if possible, to dynamically create NSmutable dictionary with the elements of the txt. For example, each is like that: id of element | date | text What I'm asking is the equivalent of the NSString stringWithFormat:. Can we do the same for an Mutable Dictionary? To be more practical, let's say the NSString *date is equal to "23/12/2009" (for europe). I want to create a dictionary called 23/12/2009 without declaring *23/12/2009 but just something like dictionaryWithFormat: @"%@", date]; I'm stuck on this, and I don't even know if it is possible. If not, what's the best way to approach that? Thanks everyone Regards

    Read the article

  • Java: serial thread confinement question

    - by denis
    Assume you have a Collection(ConcurrentLinkedQueue) of Runnables with mutable state. Thread A iterates over the Collection and hands the Runnables to an ExecutorService. The run() method changes the Runnables state. The Runnable has no internal synchronization. The above is a repetitive action and the worker threads need to see the changes made by previous iterations. So a Runnable gets processed by one worker thread after another, but is never accessed by more than one thread at a time - a case of serial thread confinement(i hope ;)). The question: Will it work just with the internal synchronization of the ConcurrentLinkedQueue/ExecutorSerivce? To be more precise: If Thread A hands Runnable R to worker thread B and B changes the state of R, and then A hands R to worker thread C..does C see the modifications done by B?

    Read the article

  • Does "Value Restriction" practically mean that there is no higher order functional programming?

    - by Sadache
    Does "Value Restriction" practically mean that there is no higher order functional programming? I have a problem that each time I try to do a bit of HOP I get caught by a VR error. Example: let simple (s:string)= fun rq->1 let oops= simple "" type 'a SimpleType= F of (int ->'a-> 'a) let get a = F(fun req -> id) let oops2= get "" and I would like to know whether it is a problem of a prticular implementation of VR or it is a general problem that has no solution in a mutable type-infered language that doesn't include mutation in the type system.

    Read the article

  • should variable be released or not? iphone-sdk

    - by psebos
    Hi, I have the following piece of code from a book. There is this function loadPrefs where the NSString *userTimeZone is being released before the end of the function. Why? The string was not created with alloc and I assume that the stringForKey function returns an autoreleased NSString. Is this an error or am I missing something? Is it an error in the book? (I new into objective-C) In the documentation for stringForKey the only thing it mentions is: Special Considerations The returned string is immutable, even if the value you originally set was a mutable string. The code: - (void) loadPrefs { timeZoneName = DefaultTimeZonePref; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSString *userTimeZone = [defaults stringForKey: TimeZonePrefKey]; if (userTimeZone != NULL) timeZoneName = userTimeZone; [userTimeZone release]; show24Hour = [defaults boolForKey:TwentyFourHourPrefKey]; } Thanks!!!!

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14  | Next Page >