Search Results

Search found 12058 results on 483 pages for 'abstract syntax tree'.

Page 13/483 | < Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >

  • Absence of property syntax in Java

    - by Vojislav Stojkovic
    C# has syntax for declaring and using properties. For example, one can declare a simple property, like this: public int Size { get; set; } One can also put a bit of logic into the property, like this: public string SizeHex { get { return String.Format("{0:X}", Size); } set { Size = int.Parse(value, NumberStyles.HexNumber); } } Regardless of whether it has logic or not, a property is used in the same way as a field: int fileSize = myFile.Size; I'm no stranger to either Java or C# -- I've used both quite a lot and I've always missed having property syntax in Java. I've read in this question that "it's highly unlikely that property support will be added in Java 7 or perhaps ever", but frankly I find it too much work to dig around in discussions, forums, blogs, comments and JSRs to find out why. So my question is: can anyone sum up why Java isn't likely to get property syntax? Is it because it's not deemed important enough when compared to other possible improvements? Are there technical (e.g. JVM-related) limitations? Is it a matter of politics? (e.g. "I've been coding in Java for 50 years now and I say we don't need no steenkin' properties!") Is it a case of bikeshedding?

    Read the article

  • How to determine if binary tree is balanced?

    - by user69514
    It's been a while from those school years. Got a job as IT specialist at a hospital. Trying to move to do some actual programming now. I'm working on binary trees now, and I was wondering what would be the best way to determine if the tree is height-balanced. I was thinking of something along this: public boolean isBalanced(Node root){ if(root==null){ return true; //tree is empty } else{ int lh = root.left.height(); int rh = root.right.height(); if(lh - rh > 1 || rh - lh > 1){ return false; } } return true; } Is this a good implementation? or am I missing something?

    Read the article

  • Tree data structure in iphone with coredata

    - by ebabchick
    Hi, I am looking to store a tree structure in CoreData for iphone. Can someone give me some tips on the best way to go about this? Basically I want to have a bunch of folders that people can dive into in a table view, and I want to have leaves of the tree be photos. The thing is, I want to be able to let the user edit these folders on-the-fly and add folders and content (photos) at their discretion. I'm relatively new to CoreData. Any help would be appreciated. Thanks.

    Read the article

  • Searching over a templated tree

    - by floatingfrisbee
    So I have 2 interfaces: A node that can have children public interface INode { IEnumeration<INode> Children { get; } void AddChild(INode node); } And a derived "Data Node" that can have data associated with it public interface IDataNode<DataType> : INode { DataType Data; IDataNode<DataType> FindNode(DataType dt); } Keep in mind that each node in the tree could have a different data type associated with it as its Data (because the INode.AddChild function just takes the base INode) Here is the implementation of the IDataNode interface: internal class DataNode<DataType> : IDataNode<DataType> { List<INode> m_Children; DataNode(DataType dt) { Data = dt; } public IEnumerable<INode> Children { get { return m_Children; } } public void AddChild(INode node) { if (null == m_Children) m_Children = new List<INode>(); m_Children.Add(node); } public DataType Data { get; private set; } Question is how do I implement the FindNode function without knowing what kinds of DataType I will encounter in the tree? public IDataNode<DataType> FindNode(DataType dt) { throw new NotImplementedException(); } } As you can imagine something like this will not work out public IDataNode<DataType> FindNode(DataType dt) { IDataNode<DataType> result = null; foreach (var child in Children) { if (child is IDataNode<DataType>) { var datachild = child as IDataNode<DataType>; if (datachild.Data.Equals(dt)) { result = child as IDataNode<DataType>; break; } } else { // What?? } } return result; } Is my only option to do this when I know what kinds of DataType a particular tree I use will have? Maybe I am going about this in the wrong way, so any tips are appreciated. Thanks!

    Read the article

  • mx:Tree not dispatching "itemClick" event when click on icon

    - by Xshare
    I have a flex tree that worked perfectly fine when we set the defaultLeafIcon={null} and the folderClosedIcon and folderOpenIcon to {null}. We decided to put the icons back in and took out the nulls. Now they show up fine, but if you click on the icon instead of the label or the rest of the row, it seems to change the selected item, shows the highlight around the new item, but doesn't dispatch the ItemClick event. This makes it really hard to know that the tree's selected item has changed! The weird part is that once you have clicked on the icon once and it looked like the selectedItem changed (or at least it applied that style), if you click the same icon again, it will actually fire the itemClick event. if you click any other icon, it does the same thing again, switching the selectedItem and styling that row, but not firing the itemClick event. Any ideas? Thanks. (This is in flex 4 btw)

    Read the article

  • how to use a tree data structure in C#

    - by matti
    I found an implementation for a tree at this SO question. Unfortunately I don't know how to use it. Also I made a change to it since LinkedList does not have Add method: delegate void TreeVisitor<T>(T nodeData); class NTree<T> { T data; List<NTree<T>> children; public NTree(T data) { this.data = data; children = new List<NTree<T>>(); } public void AddChild(T data) { children.Add(new NTree<T>(data)); } public NTree<T> GetChild(int i) { return children[i]; } public void Traverse(NTree<T> node, TreeVisitor<T> visitor) { visitor(node.data); foreach (NTree<T> kid in node.children) Traverse(kid, visitor); } } I have class named tTable and I want to store it's children and their grandchildren (...) in this tree. My need is to find immediate children and not traverse entire tree. I also might need to find children with some criteria. Let's say tTable has only name and I want to find children with names matching some criteria. tTables constructor gives name a value according to int-value (somehow). How do I use Traverse (write delegate) if I have code like this; int i = 0; Dictionary<string, NTree<tTable>> tableTreeByRootTableName = new Dictionary<string, NTree<tTable>>(); tTable aTable = new tTable(i++); tableTreeByRootTableName[aTable.Name] = new NTree(aTable); tableTreeByRootTableName[aTable.Name].AddChild(new tTable(i++)); tableTreeByRootTableName[aTable.Name].AddChild(new tTable(i++)); tableTreeByRootTableName[aTable.Name].GetChild(1).AddChild(new tTable(i++));

    Read the article

  • flex: move item around in a tree control

    - by Markus
    Hi everybody, I have a tree control and I want to give the user the ability that he can move up and down the element he just selected with a up and a downbutton. The tree gets generated from XML. I managed to insert the selected item a second time at a other place, with the following code: var parentXML:XML = XML(containerTree.selectedItem).parent(); var upperItem:XML = topContainer.source[containerTree.selectedIndex-1]; parentXML.insertChildBefore(upperItem,XML(containerTree.selectedItem)); but then I have the item there twice in the List. How can I remove to reinsert it? Thanks for Hints! Markus

    Read the article

  • Why should a class be anything other than "abstract" or "final/sealed"

    - by Nicolas Repiquet
    After 10+ years of java/c# programming, I find myself creating either: abstract classes: contract not meant to be instantiated as-is. final/sealed classes: implementation not meant to serve as base class to something else. I can't think of any situation where a simple "class" (i.e. neither abstract nor final/sealed) would be "wise programming". Why should a class be anything other than "abstract" or "final/sealed" ? EDIT This great article explains my concerns far better than I can.

    Read the article

  • How to use R-Tree for plotting large number of map markers on google maps

    - by Eeyore
    After searching SO and multiple articles I haven't found a solution to my problem. What I am trying to achieve is to load 20,000 markers on Google Maps. R-Tree seems like a good approach but it's only helpful when searching for points within the visible part of the map. When the map is zoomed out it will return all of the points and...crash the browser. There is also the problem with dragging the map and at the end of dragging re-running the query. I would like to know how I can use R-Tree and be able to achieve the all of the above.

    Read the article

  • Height of a binary tree

    - by Programmer
    Consider the following code: public int heightOfBinaryTree(Node node) { if (node == null) { return 0; } else { return 1 + Math.max(heightOfBinaryTree(node.left), heightOfBinaryTree(node.right)); } } I want to know the logical reasoning behind this code. How did people come up with it? Does some have an inductive proof? Moreover, I thought of just doing a BFS with the root of the binary tree as the argument to get the height of the binary tree. Is the previous approach better than mine?Why?

    Read the article

  • Getting a table's values into a tree

    - by Jason
    So, I have a table like such: id|root|kw1|kw2|kw3|kw4|kw5|name 1| A| B| C| D| E| F|fileA 2| A| B| | | | |fileB 3| B| C| D| E| | |fileC 4| A| B| | | | |fileD (several hundred rows...) And I need to get it into a tree like the following: *A *B -fileB -fileD *C *D *E *F -fileA *B *C *D *E -fileC I'm pretty sure the table is laid out poorly but it's what I have to live with. I've read a little about Adjacency List Model & Modified Preorder Tree Traversal but I don't think my data is laid out correctly. I think this requires a recursive function, but I'm not at all sure how to go about that. I'm open to any ideas of how to get this done even if it means extracting the data into a new table just to process this. Are there any good options available to me or any good ways to do this? (Examples are a bonus of course)

    Read the article

  • Deleting a node in a family tree

    - by user559142
    Hi, I'm trying to calclulate the best way to delete a node in a family tree. First, a little description of how the app works. My app makes the following assumption: Any node can only have one partner. That means that any child a single node has, it will also be the partner nodes child too. Therefore, step relations, divorces etc aren't compensated for. A node always has two parents - A mother and father cannot be added seperately. If the user doesn't know the details - the nodes attributes are set to a default value. Also any node can add parents, siblings, children to itself. Therefore in law relationships can be added. I have the following classes: FamilyMember String fName; String lName; String dob; String gender; FamilyMember mother, father, partner; ArrayListchildren; int index; int generation; void linkParents(); void linkPartner(); void addChild(); //gets & sets for fields Family ArrayListfamily; void addMember(); void removeMember(); FamilyMember getFamilyMember(index); ArrayListgetFamilyMembers(); FamilyTree Family family; void removeMember(); //need help void displayFamilyMembers(); void addFamilyMember(); void enterDetails(); void displayAncestors(); void displayDescendants(); void printDescendants(); FamilyMember findRootNode(); void sortGenerations(); void getRootGeneration(); I am having trouble with identifying the logic for removing a member. All other functions work fine. Has anyone developed a family tree app before who knows how to deal with removing various different nodes in the family "tree"? e.g. removing a leaf removing a leaf with partner (what if partner has parents etc) removing a parent It seems to be another recursive property but my head is swelling from over thought.

    Read the article

  • Is there any tool which can show the call tree for SQL stored procedures

    - by DBZ_A
    I have a huge SQL script which i need to analyse. It would be really helpful if i could find a tool which can generate a call tree; ie, to see which all procedures are called from a particular procedure. a perl based example is here, http://sqlblog.com/blogs/linchi_shea/archive/2009/10/23/find-the-complete-call-tree-for-a-stored-procedure.aspx but i need a tool to analyse the text file (.sql file), not the procedure stored in the database. due to some reasons i will not be able to create the whole set of procedures in the database and use the above mentioned tool. please respond if you have come across any ide/tool with this feature.

    Read the article

  • dojo dgrid tree, subrows in wrong position

    - by Ventura
    I have a dgrid, working with tree column plugin. Every time that the user click on the tree, I call the server, catch the subrows(json) and bind it. But when it happens, these subrows are show in wrong position, like the image bellow. The most strange is when I change the pagination, after go back to first page, the subrows stay on the correct place. (please, tell me if is possible to understand my english, then I can try to improve the text) My dgrid code: var CustomGrid = declare([OnDemandGrid, Keyboard, Selection, Pagination]); var grid = new CustomGrid({ columns: [ selector({label: "#", disabled: function(object){ return object.type == 'DOCx'; }}, "radio"), {label:'Id', field:'id', sortable: false}, tree({label: "Title", field:"title", sortable: true, indentWidth:20, allowDuplicates:true}), //{label:'Title', field:'title', sortable: false}, {label:'Count', field:'count', sortable: false} ], store: this.memoryStore, collapseOnRefresh:true, pagingLinks: false, pagingTextBox: true, firstLastArrows: true, pageSizeOptions: [10, 15, 25], selectionMode: "single", // for Selection; only select a single row at a time cellNavigation: false // for Keyboard; allow only row-level keyboard navigation }, "grid"); My memory store: loadMemoryStore: function(items){ this.memoryStore = Observable(new Memory({ data: items, getChildren: function(parent, options){ return this.query({parent: parent.id}, options); }, mayHaveChildren: function(parent){ return (parent.count != 0) && (parent.type != 'DOC'); } })); }, This moment I am binding the subrows: success: function(data){ for(var i=0; i<data.report.length; i++){ this.memoryStore.put({id:data.report[i].id, title:data.report[i].created, type:'DOC', parent:this.designId}); } }, I was thinking, maybe every moment that I bind the subrows, I could do like a refresh on the grid, maybe works. I think that the pagination does the same thing. Thanks. edit: I forgot the question. Well, How can I correct this bug? If The refresh in dgrid works. How can I do it? Other thing that I was thinking, maybe my getChildren is wrong, but I could not identify it. thanks again.

    Read the article

  • Implementing an iterator over binary tree using C++ 11

    - by user1459339
    I would like to create an iterator over the binary tree so as to be able to use range-based for loop. I understand I ought to implement the begin() and end() function first. Begin should probably point to the root. According to the specification, however, the end() functions returns "the element following the last valid element". Which element (node) is that? Would it not be illegal to point to some "invalid" place? The other thing is the operator++. What is the best way to return "next" element in tree? I just need some advice to begin with this programming.

    Read the article

  • Difference between Factory Method and Abstract Factory design patterns using C#.Net

    - by nijhawan.saurabh
    First of all I'll just put both these patterns in context and describe their intent as in the GOF book: Factory Method: Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.   Abstract Factory: Provide an interface for creating families of related or dependent objects without specifying their concrete classes.   Points to note:   Abstract factory pattern adds a layer of abstraction to the factory method pattern. The type of factory is not known to the client at compile time, this information is passed to the client at runtime (How it is passed is again dependent on the system, you may store this information in configuration files and the client can read it on execution). While implementing Abstract factory pattern, the factory classes can have multiple factory methods. In Abstract factory, a factory is capable of creating more than one type of product (Simpilar products are grouped together in a factory)   Sample implementation of factory method pattern   Let's see the class diagram first:                   ProductFactory.cs // ----------------------------------------------------------------------- // <copyright file="ProductFactory.cs" company=""> // TODO: Update copyright text. // </copyright> // -----------------------------------------------------------------------   namespace FactoryMethod {     using System;     using System.Collections.Generic;     using System.Linq;     using System.Text;       /// <summary>     /// TODO: Update summary.     /// </summary>     public abstract class ProductFactory     {         /// <summary>         /// </summary>         /// <returns>         /// </returns>         public abstract Product CreateProductInstance();     } }     ProductAFactory.cs // ----------------------------------------------------------------------- // <copyright file="ProductAFactory.cs" company=""> // TODO: Update copyright text. // </copyright> // -----------------------------------------------------------------------   namespace FactoryMethod {     using System;     using System.Collections.Generic;     using System.Linq;     using System.Text;       /// <summary>     /// TODO: Update summary.     /// </summary>     public class ProductAFactory:ProductFactory     {         public override Product CreateProductInstance()         {             return new ProductA();         }     } }         // ----------------------------------------------------------------------- // <copyright file="ProductBFactory.cs" company=""> // TODO: Update copyright text. // </copyright> // -----------------------------------------------------------------------   namespace FactoryMethod {     using System;     using System.Collections.Generic;     using System.Linq;     using System.Text;       /// <summary>     /// TODO: Update summary.     /// </summary>     public class ProductBFactory:ProductFactory     {         public override Product CreateProductInstance()         {             return new ProductB();           }     } }     // ----------------------------------------------------------------------- // <copyright file="Product.cs" company=""> // TODO: Update copyright text. // </copyright> // -----------------------------------------------------------------------   namespace FactoryMethod {     using System;     using System.Collections.Generic;     using System.Linq;     using System.Text;       /// <summary>     /// TODO: Update summary.     /// </summary>     public abstract class Product     {         public abstract string Name { get; set; }     } }     // ----------------------------------------------------------------------- // <copyright file="ProductA.cs" company=""> // TODO: Update copyright text. // </copyright> // -----------------------------------------------------------------------   namespace FactoryMethod {     using System;     using System.Collections.Generic;     using System.Linq;     using System.Text;       /// <summary>     /// TODO: Update summary.     /// </summary>     public class ProductA:Product     {         public ProductA()         {               Name = "ProductA";         }           public override string Name { get; set; }     } }       // ----------------------------------------------------------------------- // <copyright file="ProductB.cs" company=""> // TODO: Update copyright text. // </copyright> // -----------------------------------------------------------------------   namespace FactoryMethod {     using System;     using System.Collections.Generic;     using System.Linq;     using System.Text;       /// <summary>     /// TODO: Update summary.     /// </summary>     public class ProductB:Product     {          public ProductB()         {               Name = "ProductA";         }         public override string Name { get; set; }     } }     Program.cs using System; using System.Collections.Generic; using System.Linq; using System.Text;   namespace FactoryMethod {     class Program     {         static void Main(string[] args)         {             ProductFactory pf = new ProductAFactory();               Product product = pf.CreateProductInstance();             Console.WriteLine(product.Name);         }     } }       Normal 0 false false false false EN-US X-NONE X-NONE /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;}

    Read the article

  • Silverlight XML editor / syntax highlighting

    - by Gromix
    Hi, I am looking for a Silverlight text editor control that provides XML syntax highlighting. I found a few answers in Winforms or WPF, like here on Stackoverflow, but I didn't manage to convert them to Silverlight. The fact that Silverlight is missing System.Drawing is probably a big problem. The only text editor I found for Silverlight is RichTextEdit on Codeplex, but I don't think it is a suitable base for real-time syntax highlighting. Has anyone heard of such a control, or can provide hints on how to build one? Many thanks, Romain

    Read the article

  • Searching for a semantic syntax highlighter in Javascript

    - by Boldewyn
    OK, I know, there are literally dozens of already available syntax highlighters out there. But I want one specifically, that implements line numbers through <ol/> lists. And that reduces the number of possible candidates to one, Lighter.js. Unfortunately, that is MooTools based, and since I decided some time ago to use jQuery, I don't want to embed yet another library just for syntax highlighting. The SyntaxHighlighter does something similar, but uses tables for the line numbering, and I don't want to hack it, if there is an already available tool, too.

    Read the article

  • Syntax highlighting in MS Word document

    - by ArunSaha
    I want to insert some C/C++ source code into a Microsoft Word document. I have no problem in copying the code from source file and pasting into Word. I can do fixed-width. But, in Word, I see the code in black-and-white format; I loose the syntax highlighting as I get in the source code editor (for me, gvim). So, my question is, is there any way to do syntax highlighting of C/C++ source code in MS Word?

    Read the article

  • java equivalent of ruby's ||= syntax

    - by brad
    I'm brand new to java, coming from a ruby world. One thing I love about ruby is the very terse syntax such as ||=. I realize of course that a compiled language is different, but I'm wondering if Java has anything similar. In particular, what I do all the time in ruby is something like: someVar ||= SomeClass.new I think this is incredibly terse, yet powerful, but thus far the only method I can think of to achieve the same thing is a very verbose: if(someVar == null){ someVar = new SomeClass() } Just trying to improve my Java-fu and syntax is certainly one area that I'm no pro.

    Read the article

  • Xcode: code loses syntax coloring

    - by ColorMeFamous
    I find that in various situations Objective-C code in Xcode 3.1 (Leopard) can fail to get appropriate syntax coloring after typing or lose coloring that it had. This isn't just a "refresh" issue with new custom symbols -- but affects Cocoa framework symbols as well. Sometimes CMD-a to select all text on the code page will make the coloring (re)appear, sometimes double-clicking on a line to select it will work, sometimes I have to add/delete a space in a symbol to get that symbol to (re)color. Rebuilding, or closing/reopening the project may or may not work. Is this a known issue with Xcode? For something so annoying to me, I'm not finding the plentiful discussions of it on SO and elsewhere I'd expect. And is there any command to force global syntax recoloring?

    Read the article

< Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >