Search Results

Search found 15081 results on 604 pages for 'passing by reference'.

Page 85/604 | < Previous Page | 81 82 83 84 85 86 87 88 89 90 91 92  | Next Page >

  • reconstructing a tree from its preorder and postorder lists.

    - by NomeN
    Consider the situation where you have two lists of nodes of which all you know is that one is a representation of a preorder traversal of some tree and the other a representation of a postorder traversal of the same tree. I believe it is possible to reconstruct the tree exactly from these two lists, and I think I have an algorithm to do it, but have not proven it. As this will be a part of a masters project I need to be absolutely certain that it is possible and correct (Mathematically proven). However it will not be the focus of the project, so I was wondering if there is a source out there (i.e. paper or book) I could quote for the proof. (Maybe in TAOCP? anybody know the section possibly?) In short, I need a proven algorithm in a quotable resource that reconstructs a tree from its pre and post order traversals. Note: The tree in question will probably not be binary, or balanced, or anything that would make it too easy. Note2: Using only the preorder or the postorder list would be even better, but I do not think it is possible. Note3: A node can have any amount of children. Note4: I only care about the order of siblings. Left or right does not matter when there is only one child.

    Read the article

  • How to query through a DBRef in MongoDB/pymongo?

    - by Soviut
    Is it possible to query through a DBRef using a single find spec? user collection { 'age': 30 } post collection { 'user': DBRef('user', ...) } Is it possible to query for all post who's users are 30 in a single find step? If not, would it be wise to create a javascript function to handle the multi-stage operation or will that cause blocking problems?

    Read the article

  • Python language API

    - by Oscar Reyes
    Hello. I'm starting with Python coming from java. I was wondering if there exists something similar to JavaDoc API where I can find the class, its methods and and example of how to use it. I've found very helpul to use help( thing ) from the Python ( command line ) I have found this also: http://docs.python.org/ http://docs.python.org/modindex.html But it seems to help when you already the class name you are looking for. In JavaDoc API I have all the classes so if I need something I scroll down to a class that "sounds like" what I need. Or some times I just browse all the classes to see what they do, and when I need a feature my brain recalls me We saw something similar in the javadoc remember!? But I don't seem to find the similar in Python ( yet ) and that why I'm posting this questin. BTW I know that I would eventually will read this: http://docs.python.org/lib/lib.html But, well, I think it is not today.

    Read the article

  • Trouble cross-referencing two XML child nodes in AS3

    - by Dwayne
    I am building a mini language translator out of XML nodes and Actionscript 3. I have my XML ready. It contains a series of nodes with two children in them. Here is a sample: <translations> <entry> <english>man</english> <cockney>geeza</cockney> </entry> <entry> <english>woman</english> <cockney>lily</cockney> </entry> </translations> The AS3 part consist of one input box named "textfield_txt" where the English word will be typed in. An output text field for the translation called "cockney_txt". Finally, one button to execute the translation called "generate_mc". The idea is to have actionscript look through the XML for key English words after the user types it in the "textfield", cross-freferences the children then returns the Cockney translation as a value. The trouble is, when I test it I get no response or error messages- it's completely silent. I'm not sure what I'm doing wrong. At present, I have setup a conditional statement to tell me whether the function works or not. The result is, no it's not! Here's the code below. I hope someone can help. Cheers! generate_mc.buttonMode=true; var English:String; var myXML:XML; var myLoader:URLLoader = new URLLoader(); myLoader.load(new URLRequest("Language.xml")); myLoader.addEventListener(Event.COMPLETE, processXML); function processXML(e:Event):void { myXML = new XML(e.target.data); } generate_mc.addEventListener(MouseEvent.CLICK, onClick); function onClick(event:MouseEvent) { English = textfield.text; cockney_txt.text = myXML.translations.entry.cockney; if(textfield.text.toLowerCase() == myXML.translations.entry.english.toLowerCase){ //return myXML.translations.entry.cockney; trace("success"); }else{ trace("try again!"); // ***I get this as a result } }

    Read the article

  • Where to find algorithms for standard math functions?

    - by dsimcha
    I'm looking to submit a patch to the D programming language standard library that will allow much of std.math to be evaluated at compile time using the compile-time function evaluation facilities of the language. Compile-time function evaluation has several limitations, the most important ones being: You can't use assembly language. You can't call C code or code for which the source is otherwise unavailable. Several std.math functions violate these and compile-time versions need to be written. Where can I get information on good algorithms for computing things such as logarithms, exponents, powers, and trig functions? I prefer just high level descriptions of algorithms to actual code, for two reasons: To avoid legal ambiguity and the need to make my code look "different enough" from the source to make sure I own the copyright. I want simple, portable algorithms. I don't care about micro-optimization as long as they're at least asymptotically efficient. Edit: D's compile time function evaluation model allows floating point results computed at compile time to differ from those computed at runtime anyhow, so I don't care if my compile-time algorithms don't give exactly the same result as the runtime version as long as they aren't less accurate to a practically significant extent.

    Read the article

  • Nullable<> as TModel for ViewPage

    - by Alexander Prokofyev
    What are the possible reasons what Nullable<> types are disallowed to be passed as TModel parameter of System.Web.Mvc.ViewPage<TModel> generic? This could be handy sometimes. In ASP.NET MVC source defined what TModel should be a class: public class ViewPage<TModel> : ViewPage where TModel : class but Nullable types are value types. Maybe definition could be less restrictive...

    Read the article

  • How can I get this code involving unique_ptr to compile?!

    - by Neil G
    #include <vector> #include <memory> using namespace std; class A { public: A(): i(new int) {} A(A const& a) = delete; A(A &&a): i(move(a.i)) {} unique_ptr<int> i; }; class AGroup { public: void AddA(A &&a) { a_.emplace_back(move(a)); } vector<A> a_; }; int main() { AGroup ag; ag.AddA(A()); return 0; } does not compile... (says that unique_ptr's copy constructor is deleted) I tried replacing move with forward. Not sure if I did it right, but it didn't work for me.

    Read the article

  • Perl - MySQL connection problem in windows

    - by dexter
    I have two folders php and perl they contain index.php and index.pl respectivly in index.pl my perl code looks like: #!/usr/bin/perl use Mysql; print "Content-type: text/html\n\n"; print "<h2>PERL-mySQL Connect</h2>"; print "page info"; $host = "localhost"; $database = "cdcol"; $user = "root"; $password = ""; $db = Mysql->connect($host, $database, $user, $password); $db->selectdb($database); when i run above code (ie type: http://localhost:88/perl/ in browser) following error comes Error message: Can't locate Mysql.pm in @INC (@INC contains: C:/xampp/perl/site/lib/ C:/xampp/perl/lib C:/xampp/perl/site/lib C:/xampp/apache) at C:/xampp/htdocs/perl/index.pl line 2. BEGIN failed--compilation aborted at C:/xampp/htdocs/perl/index.pl line 2. while this works: in browser http://localhost:88/php/ where index.php has: <?php $con = mysql_connect("localhost","root",""); if($con) { if(mysql_select_db("cdcol", $con)) { $sql="SELECT Id From products"; if(mysql_query($sql)) { $result = mysql_query($sql); if ($result)............

    Read the article

  • Python minidom and UTF-8 encoded XML with hash references

    - by Jakob Simon-Gaarde
    Hi I am experiencing some difficulty in my home project where I need to parse a SOAP request. The SOAP is generated with gSOAP and involves string parameters with special characters like the danish letters "æøå". gSOAP builds SOAP requests with UTF-8 encoding by default, but instead of sending the special chatacters in raw format (ie. bytes C3A6 for the special character "æ") it sends what I think is called character hash references (ie. &#195;&#166;). I don't completely understand why gSOAP does it this way as I can see that it has marked the incomming payload as being UTF-8 encoded anyway (Content-Type: text/xml; charset=utf-8), but this is besides the question (I think). Anyway I guess gSOAP probably is obeying transport rules, or what? When I parse the request from gSOAP in python with xml.dom.minidom.parseString() I get element values as unicode objects which is fine, but the character hash references are not decoded as UTF-8 character codes. It unescapes the character hash references, but does not decode the string afterwards. In the end I have a unicode string object with UTF-8 encoding: So if the string "æble" is contained in the XML, it comes like this in the request: "&#195;&#166;ble" After parsing the XML the unicode string in the DOM Text Node's data member looks like this: u'\xc3\xa6ble' I would expect it to look like this: u'\xe6ble' What am I doing wrong? Should I unescape the SOAP XML before parsing it, or is it somewhere else I should be looking for the solution, maybe gSOAP? Thanks in advance. Best regards Jakob Simon-Gaarde

    Read the article

  • References between ASP.NET web applications.

    - by mcoolbeth
    I have a Visual Studio solution containing two web applications. I would like the first to depend on the second (pages in the first may contain links to, or possibly post to pages in the second). Furthermore, I would like to be able to launch the first project on a development server (standard debugging procedure for web apps in VS) and have the references to the second project be fully functional. Does anyone know the best way to achieve this? Thanks.

    Read the article

  • PHP Extended CHM Manual Gone?

    - by Alix Axel
    I'm sorry for maybe posting a question that may not be directly related to programming but where can I find an up to date version of the Extended PHP Manual (the one with the user comments) for download? The usual URL (http://www.php.net/docs-echm.php) seems to redirect to the (http://www.php.net/download-docs.php), was it discontinued?

    Read the article

  • .NET application silently fails to start when assembly missing

    - by chiccodoro
    I have a .NET C# winforms application which works great on my machine, but if I try to run it on another machine, it doesn't start up. No error message, no crash message, no window - nothing. I've found that this always happens when a referenced assembly is missing. I guess this is .NET's general behavior and not specific to my app, is it? Is there any way to configure .NET or my application such that it spits out a "referenced assembly missing" like error message in such cases?

    Read the article

  • Equivalent of http://www.cplusplus.com/ for C# .net

    - by David Relihan
    Hi Folks I've read through a lot of the "Learn C# .Net" questions just to see if this question was answered already (directly or indirectly). I program mostly in C++ so I find the website http://www.cplusplus.com/ invaluable and there's rarely a day when it is not open in my browser! However, I'm just wondering is there an C# .Net equivalent that people find themselves constantly referencing? The best I'm aware of is: http://stackoverflow.com http://msdn.microsoft.com/en-us/vcsharp/aa336809.aspx http://www.java2s.com/Tutorial/CSharp/CatalogCSharp.htm Thanks,

    Read the article

  • What's wrong with this javascript?

    - by Arlen Beiler
    What's wrong with this code? var divarray = document.getElementById("yui-main").getElementsByTagName("div"); var articleHTML = array(); var absHTML; var keyHTML; var bodyHTML = array(); var i = 0; for ( var j in divarray) { if(divarray[i].className == "articleBody"){ alert("found"); articleHTML = divarray[i]; break; } bodyHTML[i] = ''; if(articleHTML[i].className == "issueMiniFeature"){continue;} if(articleHTML[i].className == "abstract"){absHTML = articleHTML[i]; continue;} if(articleHTML[i].className == "journalKeywords"){keyHTML = articleHTML[i]; continue;} bodyHTML[i] = articleHTML[i]; i++; } This is the error I am getting: ReferenceError: array is not defined I am using Google Chrome if it helps any.

    Read the article

  • On reference_wrapper and callable objects

    - by Nicola Bonelli
    Given the following callable object: struct callable : public std::unary_function &lt;void, void&gt; { void operator()() const { std::cout << "hello world" << std::endl; } }; a std::tr1::reference_wrapper< calls through it: callable obj; std::tr1::ref(obj)(); Instead, when the operator() accepts an argument: struct callable : public std::unary_function &lt;int, void&gt; { void operator()(int n) const { std::cout << n << std::endl; } }; std::tr1::bind accepts a reference_wrapper to it as a callable wrapper... callable obj; std::tr1::bind( std::tr1::ref(obj), 42 )(); but what's wrong with this? std::tr1::ref(obj)(42);

    Read the article

  • Storing expression references to data base

    - by Marcus
    I have standard arithmetic expressions sotred as strings eg. "WIDTH * 2 + HEIGHT * 2" In this example WIDTH and HEIGHT references other objects in my system and the literals WIDTH and HEIGHT refers to a property (Name) on those objects. The problem I'm having is when the Name property on an expression object changes the expression won't match anymore. One solution I came up with is to instead of storing "WIDTH * 2 + HEIGHT * 2" i store "{ID_OF_WIDTH} * 2 + {ID_OF_HEIGHT} * 2" And let my parser be able to parse this new syntax and implement an interface or such on referenced objects IExpressionReference { string IdentifierName { get; } } Anyone have a better/alternative solution to my problem?

    Read the article

  • stored as array understanding mongoid

    - by Gagan
    Hello frens, This is not a problem, but I just want to know stored as array of Mongoid better. I have following code in my model. class Company include Mongoid::Document include Mongoid::Timestamps references_many :people, :stored_as => :array, :inverse_of => :companies end class Person include Mongoid::Document include Sunspot::Mongoid references_many :companies, :stored_as => :array, :inverse_of => :people end Now in Company object we get person_ids as a result of stored_as array and company_ids in Person object. Now initially I inserted lots of person in company and the ids in person_ids fields is huge. Now I deleted most of person from company down to 8 people. Now I don't get why person_ids fields of Company object storing all the deleted ids of person. My console snapshot is follwing ruby-1.9.2-head Company.first.person_ids = [BSON::ObjectId('4d12d2907adf350695000025'), BSON::ObjectId('4d12d2907adf35069500002c'), BSON::ObjectId('4d12d2907adf350695000035'), BSON::ObjectId('4d12d2907adf35069500003f'), BSON::ObjectId('4d12d2907adf350695000048'), BSON::ObjectId('4d12d2907adf350695000052'), BSON::ObjectId('4d12d2907adf350695000059'), BSON::ObjectId('4d12d2907adf350695000062'), BSON::ObjectId('4d12d4017adf35069500008d'), BSON::ObjectId('4d12d4017adf350695000094'), BSON::ObjectId('4d12d4017adf35069500009d'), BSON::ObjectId('4d12d4017adf3506950000a7'), BSON::ObjectId('4d12d4017adf3506950000b0'), BSON::ObjectId('4d12d4017adf3506950000ba'), BSON::ObjectId('4d12d4017adf3506950000c1'), BSON::ObjectId('4d12d4017adf3506950000ca'), BSON::ObjectId('4d12d48a7adf3506950000f5'), BSON::ObjectId('4d12d48a7adf3506950000fc'), BSON::ObjectId('4d12d48a7adf350695000108'), BSON::ObjectId('4d12d48b7adf350695000115'), BSON::ObjectId('4d12d48b7adf350695000121'), BSON::ObjectId('4d12d48b7adf35069500012e'), BSON::ObjectId('4d12d48b7adf350695000135'), BSON::ObjectId('4d12d48b7adf350695000141'), BSON::ObjectId('4d12d53e7adf35069500016f'), BSON::ObjectId('4d12d53e7adf350695000176'), BSON::ObjectId('4d12d53e7adf350695000182'), BSON::ObjectId('4d12d53e7adf35069500018f'), BSON::ObjectId('4d12d53e7adf35069500019b'), BSON::ObjectId('4d12d53f7adf3506950001a8'), BSON::ObjectId('4d12d53f7adf3506950001af'), BSON::ObjectId('4d12d53f7adf3506950001bb'), BSON::ObjectId('4d12d8587adf3506950001e9'), BSON::ObjectId('4d12d8587adf3506950001f0'), BSON::ObjectId('4d12d8587adf3506950001ff'), BSON::ObjectId('4d12d8597adf35069500020f'), BSON::ObjectId('4d12d8597adf35069500021e'), BSON::ObjectId('4d12d8597adf35069500022e'), BSON::ObjectId('4d12d8597adf350695000235'), BSON::ObjectId('4d12d85a7adf350695000244'), BSON::ObjectId('4d12d9587adf35069500025b'), BSON::ObjectId('4d12db8b7adf35069500026a'), BSON::ObjectId('4d12de6f7adf3509c9000024'), BSON::ObjectId('4d12de6f7adf3509c900002b'), BSON::ObjectId('4d12de6f7adf3509c900003a'), BSON::ObjectId('4d12de707adf3509c900004a'), BSON::ObjectId('4d12de707adf3509c9000059'), BSON::ObjectId('4d12de707adf3509c9000069'), BSON::ObjectId('4d12de707adf3509c9000070'), BSON::ObjectId('4d12de717adf3509c900007f'), BSON::ObjectId('4d12e7f27adf350bd2000009'), BSON::ObjectId('4d12e81f7adf350bd2000015'), BSON::ObjectId('4d12e87f7adf350bd2000024'), BSON::ObjectId('4d12e8b87adf350bd200004c'), BSON::ObjectId('4d12e8b97adf350bd2000053'), BSON::ObjectId('4d12e8b97adf350bd200005c'), BSON::ObjectId('4d12e8b97adf350bd2000066'), BSON::ObjectId('4d12e8b97adf350bd200006f'), BSON::ObjectId('4d12e8b97adf350bd2000079'), BSON::ObjectId('4d12e8ba7adf350bd2000080'), BSON::ObjectId('4d12e8ba7adf350bd2000089'), BSON::ObjectId('4d12ee6b7adf350bd2000198'), BSON::ObjectId('4d12ee6b7adf350bd200019f'), BSON::ObjectId('4d12ee6c7adf350bd20001a5'), BSON::ObjectId('4d12ee6c7adf350bd20001ac'), BSON::ObjectId('4d12ee6c7adf350bd20001b2'), BSON::ObjectId('4d12ee6c7adf350bd20001b9'), BSON::ObjectId('4d12ee6c7adf350bd20001c0'), BSON::ObjectId('4d12ee6c7adf350bd20001c6'), BSON::ObjectId('4d141ca57adf35033e00006e'), BSON::ObjectId('4d141ca57adf35033e000075'), BSON::ObjectId('4d1420aa7adf350705000003'), BSON::ObjectId('4d1420aa7adf35070500000a'), BSON::ObjectId('4d1420f47adf350705000011'), BSON::ObjectId('4d1420f57adf350705000015'), BSON::ObjectId('4d1420f57adf350705000018'), BSON::ObjectId('4d1420f57adf35070500001c'), BSON::ObjectId('4d1420f57adf350705000023'), BSON::ObjectId('4d1420f57adf350705000026'), BSON::ObjectId('4d14215f7adf35070500004b'), BSON::ObjectId('4d14215f7adf350705000052'), BSON::ObjectId('4d14215f7adf350705000055'), BSON::ObjectId('4d14215f7adf350705000059'), BSON::ObjectId('4d14215f7adf35070500005c'), BSON::ObjectId('4d14215f7adf350705000060'), BSON::ObjectId('4d14215f7adf350705000067'), BSON::ObjectId('4d14215f7adf35070500006a')] Company.first.people.collect(&:id) = [BSON::ObjectId('4d14215f7adf35070500004b'), BSON::ObjectId('4d14215f7adf350705000052'), BSON::ObjectId('4d14215f7adf350705000055'), BSON::ObjectId('4d14215f7adf350705000059'), BSON::ObjectId('4d14215f7adf35070500005c'), BSON::ObjectId('4d14215f7adf350705000060'), BSON::ObjectId('4d14215f7adf350705000067'), BSON::ObjectId('4d14215f7adf35070500006a')] Isn't the Company.first.person_ids array be only storing the ids shown by Company.first.people.collect(&:id) It would be helpful if some one tell me when to best use stored_as = :array method. Do stored_as = :array increase querying performance? Thanks

    Read the article

  • Move from *this in an rvalue method?

    - by FredOverflow
    In C++0x, methods can be overloaded on whether or not the expression that denotes the object on which the method is called is an lvalue or an rvalue. If I return *this from a method called via an rvalue, do I need to explicitly move from *this or not? Foo Foo::method() && { return std::move(*this); // Is this move required or not? } Unfortunately, I can't simply test this on my compiler since g++ does not support this feature yet :(

    Read the article

  • Why Can I Change Struct's int[] Property from Method Without Specifying "ref"?

    - by AMissico
    From a method, I can pass a struct which contains an array of integers, and change the values in the array. I am not sure I understand fully why I can do this. Can someone please explain why I can change the values stored in the int[]? private void DoIt(){ SearchInfo a = new SearchInfo(); a.Index = 1; a.Map = new int[] { 1 }; SearchInfo b = new SearchInfo(); b.Index = 1; b.Map = new int[] { 1 }; ModifyA(a); ModifyB(ref b); Debug.Assert(a.Index == 1); Debug.Assert(a.Map[0] == 1, "why did this change?"); Debug.Assert(b.Index == 99); Debug.Assert(b.Map[0] == 99); } void ModifyA(SearchInfo a) { a.Index = 99; a.Map[0] = 99; } void ModifyB(ref SearchInfo b) { b.Index = 99; b.Map[0] = 99; } struct SearchInfo { public int[] Map; public int Index; }

    Read the article

  • Silverlight 4 Assembly Sharing Problem

    - by jeffn825
    I have a WPF .NET 4.0 class library referencing a Silverlight 4 class library. The SL library compiles fine but when I compile the WPF class library, I get: Error 2 Unknown build error, 'Cannot resolve dependency to assembly 'System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event.' MyProj.Presentation.Wpf I figure the problem must be similar to the one mentioned here: http://markti.spaces.live.com/blog/cns!D92CF278F0F91957!273.entry but my WPF library doesn't contain any XAML that references a user control from my SL library. In fact, my SL library doesn't have any XAML in it at all. It does, however, have several shared DependencyObjects, such as an EventCommander (binding UI element events to Commands), and some DataTemplate helpers. Is there any way I can narrow down the problem here? And has anyone found a way of effectively referencing UI elements in a SL4 project from .NET 4.0? Thanks.

    Read the article

  • Should I use the ref or out keyword here?

    - by Blankman
    I have an object that may be null, which I will pass to a method that will set its properties. So my code looks like: User user = null; // may or may not be null at this point. SetUserProperties(user); UpdateUser(user); public void SetUserProperties(User user) { if(user == null) user = new User(); user.Firstname = "blah"; .... } So I am updating the same object I pass into SetUserProperties. Should I use the 'ref' keyword in my method SetUserProperties?

    Read the article

< Previous Page | 81 82 83 84 85 86 87 88 89 90 91 92  | Next Page >