Search Results

Search found 4012 results on 161 pages for 'concept hierarchy'.

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

  • Java Threading Concept Understanding

    - by Nirmal
    Hello All... Recently I have gone through with one simple threading program, which leads me some issues for the related concepts... My sample program code looks like : class NewThread implements Runnable { Thread t; NewThread() { t = new Thread(this, "Demo Thread"); System.out.println("Child thread: " + t); t.start(); // Start the thread } public void run() { try { for (int i = 5; i > 0; i--) { System.out.println("Child Thread: " + i); Thread.sleep(500); } } catch (InterruptedException e) { System.out.println("Child interrupted."); } System.out.println("Exiting child thread."); } } class ThreadDemo { public static void main(String args[]) { new NewThread(); // create a new thread try { for (int i = 5; i > 0; i--) { System.out.println("Main Thread: " + i); Thread.sleep(1000); } } catch (InterruptedException e) { System.out.println("Main thread interrupted."); } System.out.println("Main thread exiting."); } } Now this program giving me the output as follows : Child thread: Thread[Demo Thread,5,main] Main Thread: 5 Child Thread: 5 Child Thread: 4 Main Thread: 4 Child Thread: 3 Child Thread: 2 Main Thread: 3 Child Thread: 1 Exiting child thread. Main Thread: 2 Main Thread: 1 Main thread exiting. So, that's very much clear to me. But as soon as I am replacing the object creation code (calling of a NewThread class constructor) to as follows : NewThread nt = new NewThread(); // create a new thread the output becomes a bit varied like as follows : Child thread: Thread[Demo Thread,5,main] Main Thread: 5 Child Thread: 5 Child Thread: 4 Child Thread: 3 Main Thread: 4 Child Thread: 2 Child Thread: 1 Main Thread: 3 Exiting child thread. Main Thread: 2 Main Thread: 1 Main thread exiting. And some times it's giving me same output in both the cases. So, i am not getting the exact change in both the scenario. I would like to know that you the variation in the output is coming here ? Thanks in advance...

    Read the article

  • android R.layout concept

    - by yoav.str
    can I genrate java code instead using xml code ? lets say i want to do this xml code in a loop : <TableRow android:id="@+id/LivingCreture" android:layout_width="wrap_content" android:layout_height="wrap_content"> <TextView android:text="LivingCreture" android:gravity="left" android:id="@+id/LivingCretureT" android:layout_width="45dp" android:layout_height="45dp"></TextView> <EditText android:text=" " android:gravity="center" android:id="@+id/LivingCretureE" android:layout_width="45dp" android:layout_height="45dp"></EditText> <ImageView android:id="@+id/ImageView03" android:layout_width="wrap_content"android:layout_height="wrap_content"></ImageView> is it possiable ?

    Read the article

  • How to structure a Genetic Algorithm class hierarchy?

    - by MahlerFive
    I'm doing some work with Genetic Algorithms and want to write my own GA classes. Since a GA can have different ways of doing selection, mutation, cross-over, generating an initial population, calculating fitness, and terminating the algorithm, I need a way to plug in different combinations of these. My initial approach was to have an abstract class that had all of these methods defined as pure virtual, and any concrete class would have to implement them. If I want to try out two GAs that are the same but with different cross-over methods for example, I would have to make an abstract class that inherits from GeneticAlgorithm and implements all the methods except the cross-over method, then two concrete classes that inherit from this class and only implement the cross-over method. The downside to this is that every time I want to swap out a method or two to try out something new I have to make one or more new classes. Is there another approach that might apply better to this problem?

    Read the article

  • Getting hierarchy data from a self-referencing table

    - by Emanuil
    Let's say you have the following table: items(item_id, item_parent) ... and it is a self-referencing table as item_parent refers to item_id. What SQL query would you use to SELECT all items in the table along with their depth where the depth of an item is the sum of all parents and grand parents of that item. If the following is the content of the table: item_id item_parent ----------- ----------- 1 0 2 0 3 2 4 2 5 3 ... the query should retrieve the following set of objects: {"item_id":1,"depth":0} {"item_id":2,"depth":0} {"item_id":3,"depth":1} {"item_id":4,"depth":1} {"item_id":5,"depth":2} P.S. I'm looking for a MySQL supported approach.

    Read the article

  • Find the flaws in the concept...

    - by Trindaz
    A web based web browser. Sounds silly right? Here's a use case. All comments about what could go wrong, and if anyone has tried and failed at this, very much wanted User goes to www.theBrowser.com and logs in with credentials specific to theBrowser.com. User tells theBrowser what their username and password for various sites are User goes to theBrowser.com/?uri=somesite.com theBrowser sends off the http request with User's log in details, then sends the http response back to User. This lets theBrowser do weird and wonderful functions like change colours / style sheets / etc. to every site that gets passed through it. From a technical stand point, storing username and password and passing them along is not a challenge for one user, but if there were a few, I'd have to use some kind of server based browser software to store a session per user logged in at theBrowser.com. How could I do that? Will I have to start from scratch? Obviously privacy and security are issues. Would theBrowser.com be too great a risk, even if users are fully warned? Cheers, Dave

    Read the article

  • Why the concept of "Covariance" and "Contravariance" are applicable while implementing the methods o

    - by Amy
    The use case is some what like this: public class SomeClass: IClonable { // Some Code //Implementing interface method Public object Clone() { //Some Clonning Code } } Now my question is "Why is it not possible to use "SomeClass(As it is derivd from objec)" as a return type of Clone() method if we consider the Funda's of Covariance and Contravariance. Can somebody explain me the reason behind this implemementaion of Microsoft ????

    Read the article

  • When and how should custom hierarchies be used in clojure?

    - by Rob Lachlan
    Clojure's system for creating an ad hoc hierarchy of keywords is familiar to most people who have spent a bit of time with the language. For example, most demos and presentations of the language include examples such as (derive ::child ::parent) and they go on to show how this can be used for multi-method dispatch. In all of the slides and presentations that I've seen, they use the global hierarchy. But it is possible to keyword relationships in custom hierarchies. Some questions, therefore: Are there any guidelines on when this is useful or necessary? Are there any functions for manipulating hierarchies? Merging is particularly useful, so I do this: (defn merge-h [& hierarchies] (apply merge-with (cons #(merge-with clojure.set/union %1 %2) hierarchies)) But I was wondering if such functions already exist somewhere.

    Read the article

  • Unable to specify abstract classes in TPH hierarchy in Entity Framework 4

    - by Lee Atkinson
    Hi I have a TPH heirachy along the lines of: A-B-C-D A-B-C-E A-F-G-H A-F-G-I I have A as Abstract, and all the other classes are concrete with a single discriminator column. This works fine, but I want C and G to be abstract also. If I do that, and remove their discriminators from the mapping, I get error 3034 'Two entities with different keys are mapped to the same row'. I cannot see how this statement can be correct, so I assume it's a bug in some way. Is it possible to do the above? Lee

    Read the article

  • Logfile per Component Hierarchy

    - by Daniel Marbach
    Hello I have the following problem: ComponentA with Unique Name ChildComponent ChildChild AnotherChild Everytime a new instance of ComponentA is created I want to redirect the output to a unique file named ComponentA-UniqueName including all child component log entries. How can this be achieved? Daniel

    Read the article

  • TFS Best Practices Project Hierarchy

    - by CWinKY
    I've recently installed and started using TFS. Mainly using for source repository initially and then will get into using the Work Item features. I'm moving from using Vault as repository and have some questions on best practices for setting up the project structure. My current structure from Vault is: Projects - CustomerName1 -- Application1 -- Application2 - CustomerName2 -- Application1 -- Application2 Can I have a smiliar structure in TFS? Is there any good documentation that has real examples and instructions on how to set this up? From what I see is all real basic and the books I have don't have real-life repository examples that mimic the structure I have. I have created a new Team Project called CustomerName1, then added other Team Projects, Application1, underneath CustomerName1. However, I lose on the Application1 the separate folders like Work Items, Documents, Reports, and Builds. So this doesn't appear set-up correctly. Thanks ...

    Read the article

  • Concept of GUI's - Centralized or decentralized

    - by wvd
    Hello all, Since a few months I've been learning Erlang, and now it was time to do some basic GUI. After some quick research I saw there was an interesting library called 'wxi' (based on Fudgets of Haskell) which uses a different approach on GUI's. No central loop, every widget processes it's own events and handles it's own data. What do you guys think about this? It looks like it kind of can be efficient in languages such as Erlang, and it's an interesting approach. William van Doorn

    Read the article

  • iPhone: Creating a hierarchy-based table navigation.

    - by Jack Griffiths
    Hi there, I've tried to ask this before, but nothing got answered. Basically, I would like someone to explain to me how to create a table, which when a cell is tapped, pushes the user to the next view for that cell. I have this so far: Click here to view what I have. I would further like to, say when CSS is tapped, it goes to a new view which has another table in it. This table would then take the user to a detail view, which is scrollable and you can switch pages through it. I would appreciate longer, more structured tutorials on how to do each and every bit to get it to work. Here's my array in my implementation file: - (void)viewDidLoad { arryClientSide = [[NSArray alloc] initWithObjects:@"CSS", @"HTML", @"JavaScript", @"XML", nil]; arryServerSide = [[NSArray alloc] initWithObjects:@"Apache", @"PHP", @"SQL", nil]; self.title = @"Select a Language"; [super viewDidLoad]; } and my .h: @interface RootViewController : UITableViewController <UITableViewDelegate, UITableViewDataSource> { IBOutlet UITableView *tblSimpleTable; NSArray *arryClientSide; NSArray *arryServerSide; } My current code crashes the script, and this error is returned in the console: Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] loaded the "NextView" nib but didn't get a UITableView.' If that error is the source of why it's not pushing, then an explanation of how to remedy that would also be appreciated Many thanks, Jack

    Read the article

  • function concept

    - by anurag18294
    void execute(int &x,int y=100) { x=x+y; cout< will the following program work in spite of not assigning a default value to the x(formal parameters in the fuction prototype).

    Read the article

  • need more complex index !

    - by silversky
    I'm sorry if it's not an appropriate question for this site, and if it's necesary I'll close this question. But maybe someone could give me an ideea: I'm trying to find a more complex index to make an hierarchy. For example: 5 votes from 6 = 83% AND 500 votes from 600 = 83%; 10 votes from 600 = 1.66% If I make a hierarchy with the %, first two will be on the same place, but I think that 83% from 600 it's more valuable than the first one. I could compare 5, 10, 500, but again it's not fair because the third case (10 votes) will be in front of the first case (5 votes), wich it's not fair beacuse the third case has only 1.66% Maybe someone could give me an ideea how to give more weight for the second case but in the same time let the let the new entries have a fair chance.

    Read the article

  • Statement hierarchy in programming languages

    - by sudo
    I quickly wrote an interpreter for some sort of experimental programing language i came up with, in PHP (yes, in PHP). The language itself doesn't have anything really special, I just wanted to give it a try. I got the basic things working (Hello World, input to output, string manipulation, arithmetics) but I'm getting stuck with the management of blocks and grouped statements. What I mean is: PHP and most other languages let you do this: ((2+2)*(8+2)+2), of course not only with mathematical computations. My program structure currently consists of a multidimensional array built like this: ID => Type (Identifier, String, Int, Newline, EOF, Comma, ...) Contents (If identifier, int or string) How could I allow statements to be executed in a defined order like in the PHP example above?

    Read the article

  • ASP.NET MVC 2 AJAX dilemma: Lose Models concept or create unmanageable JavaScript

    - by Slightly Frustrated
    Hi, Ok, let's assume we are working with ASP.NET MVC 2 (latest and greatest preview) and we want to create AJAX user interface with jQuery. So what are our real options here? Option 1 - Pass Json from the Controller to the view, and then the view submits Json back to the controller. This means (in the order given): User opens some View (let's say - /Invoices/January) which has to visualize a list of data (e.g. <IEnumerable<X.Y.Z.Models.Invoice>>) Controller retrieves the Model from the repository (assuming we are using repository pattern). Controller creates a new instance of a class which we will serialize to Json. The reasaon we do this, is because the model may not be serializable (circular reference ftl) Controller populates the soon-to-be-serialized class with data Controller serializes the class to Json and passes it the view. User does some change and submits the 'form' The View submits back Json to the controller The Controller now must 'manually' validate the input, because the Json passed does not bind to a Model See, if our View is communicating to the controller via Json, we lose the Model validation, which IMHO is incredible disadvantage. In this case, forget about data annotations and stuff. Option 2 - Ok, the alternative of the first approach is to pass the Models to the Views, which is the default behavior in the template when you start a new project. We pass a strong typed model to the view The view renders the appropriate html and javascript, sticking to the model property names. This is important! The user submits the form. If we stick to the model names, when we .serialize() the form and submit it to the controller it will map to a model. There is no Json mapping. The submitted form directly binds to a strongly typed model, hence, we can use the model validation. E.g. we keep the business logic where it should be. Problem with this approach is, if we refactor some of the Models (change property names, types, etc), the javascript we wrote would become invalid. We will have to manually refactor the scripting and hope we don't miss something. There is no way you can test it either. Ok, the question is - how to write an AJAX front end, which keeps the business logic validation in the model (e.g. controller passes and receives a Model type), but in the same time doesn't screw up the javascript and html when we refactor the model?

    Read the article

  • Class hierarchy problem (with generic's variance!)

    - by devoured elysium
    The problem: class StatesChain : IState, IHasStateList { private TasksChain tasks = new TasksChain(); ... public IList<IState> States { get { return _taskChain.Tasks; } } IList<ITask> IHasTasksCollection.Tasks { get { return _taskChain.Tasks; } <-- ERROR! You can't do this in C#! I want to return an IList<ITask> from an IList<IStates>. } } Assuming the IList returned will be read-only, I know that what I'm trying to achieve is safe (or is it not?). Is there any way I can accomplish what I'm trying? I wouldn't want to try to implement myself the TasksChain algorithm (again!), as it would be error prone and would lead to code duplication. Maybe I could just define an abstract Chain and then implement both TasksChain and StatesChain from there? Or maybe implementing a Chain<T> class? How would you approach this situation? The Details: I have defined an ITask interface: public interface ITask { bool Run(); ITask FailureTask { get; } } and a IState interface that inherits from ITask: public interface IState : ITask { IState FailureState { get; } } I have also defined an IHasTasksList interface: interface IHasTasksList { List<Tasks> Tasks { get; } } and an IHasStatesList: interface IHasTasksList { List<Tasks> States { get; } } Now, I have defined a TasksChain, that is a class that has some code logic that will manipulate a chain of tasks (beware that TasksChain is itself a kind of ITask!): class TasksChain : ITask, IHasTasksList { IList<ITask> tasks = new List<ITask>(); ... public List<ITask> Tasks { get { return _tasks; } } ... } I am implementing a State the following way: public class State : IState { private readonly TaskChain _taskChain = new TaskChain(); public State(Precondition precondition, Execution execution) { _taskChain.Tasks.Add(precondition); _taskChain.Tasks.Add(execution); } public bool Run() { return _taskChain.Run(); } public IState FailureState { get { return (IState)_taskChain.Tasks[0].FailureTask; } } ITask ITask.FailureTask { get { return FailureState; } } } which, as you can see, makes use of explicit interface implementations to "hide" FailureTask and instead show FailureState property. The problem comes from the fact that I also want to define a StatesChain, that inherits both from IState and IHasStateList (and that also imples ITask and IHasTaskList, implemented as explicit interfaces) and I want it to also hide IHasTaskList's Tasks and only show IHasStateList's States. (What is contained in "The problem" section should really be after this, but I thought puting it first would be way more reader friendly). (pff..long text) Thanks!

    Read the article

  • DATE concept in VB.NET

    - by megala
    i have created VB.net project.In that i have two textbox,and two buttons button1--submit buttom2-Duedate textbox1 contain the current date My constraints is if i click button2(Duedate) than add 30 days to textbox1 date and assign that value into textbox2. How to achieve this? I want the result like as folloes If I give textbox1 = 12/12/2009 than I click Duedatetextbox2.text =11/1/2010 Is it possible. Thanks in advance.

    Read the article

  • File Hierarchy system with a web application logic question: List searching

    - by molleman
    I need to search through a list of folders that could have more folders inside it, and add a new folder depending what folder is its parent.(the path is stored as a String for eg = "root/MyCom/home/") Then i fill in a field with a new folder name and add it to the final folder(eg "home/"). Below as you can see , I can navigate to the right location and add the new folder to a current folder, My trouble is that i cannot ensure that currentFolder element is placed back in the list it came from how could i add a folder to a list of folders, that could be within a list of folders,that could be within a list of folders and endless more? YFUser user = (YFUser)getSession().getAttribute(SESSION_USER); Folder newFolder = new Folder(); newFolder.setFolderName(foldername); // this is the path string (root/MyCom/home/) split in the different folder names String folderNames[] = folderLocationString.split("/"); int folderNamesLength = folderNames.length; Folder root = user.getRoot(); Folder currentFolder = root; for(int i=0;i<=folderNamesLength; i++){ // because root is folderNames[i] String folderName = folderNames[i++]; int currentFolderSize = currentFolder.getChildren.getSize(); for(int o=1; o<= currentFolderSize ; o++){ if(currentFolder.getChildren().get(o) instanceof Folder){ if(folderName.equals(currentFolder.getChildren().get(o).getFolderName())){ currentFolder = currentFolder.getChildren().get(o); if (i == counter){ //now i am inside the correct folder and i add it to the list of folders within it //the trouble is knowing how to re add this changed folder back to the list before it currentFolder.getChildren.add(newFolder); } } } } }

    Read the article

  • MUD (game) design concept question about timed events.

    - by mudder
    I'm trying my hand at building a MUD (multiplayer interactive-fiction game) I'm in the design/conceptualizing phase and I've run into a problem that I can't come up with a solution for. I'm hoping some more experienced programmers will have some advice. Here's the problem as best I can explain it. When the player decides to perform an action he sends a command to the server. the server then processes the command, determines whether or not the action can be performed, and either does it or responds with a reason as to why it could not be done. One reason that an action might fail is that the player is busy doing something else. For instance, if a player is mid-fight and has just swung a massive broadsword, it might take 3 seconds before he can repeat this action. If the player attempts to swing again to soon, the game will respond indicating that he must wait x seconds before doing that. Now, this I can probably design without much trouble. The problem I'm having is how I can replicate this behavior from AI creatures. All of the events that are being performed by the server ON ITS OWN, aka not as an immediate reaction to something a player has done, will have to be time sensitive. Some evil monster has cast a spell on you but must wait 30 seconds before doing it again... I think I'll probably be adding all these events to some kind of event queue, but how can I make that event queue time sensitive?

    Read the article

  • Mixing table per subclass and per hierarchy in hibernate

    - by Xelluloid
    In my database there are two three tables. The first one, table ABSTRACT, holds three columns id, type, someText This table contains all abstract information for the abstract class abstract. Now the two tables CONCRETEONE and CONCRETETWO contain all information for the concrete classes concreteOne and concreteTwo. Now I know I could use the table per subclass strategy from hibernate to create a mapping with inheritance. But as I have a column that marks the type of the concrete implementation could it be possible to create some mixed behaviour like a table per subclass strategy with an discriminator?

    Read the article

  • help understanding the concept of javascript callbacks with node.js, especially in loops

    - by Mr JSON
    hi I am just starting with node.js. I have done a little ajax stuff but nothing too complicated so callbacks are still kind of over my head. I looked at async but all I need is to run a few functions sequentially. I basically have something that pulls some json from an api, creates a new one and then does something with that. obviously i can't just run it because it runs everything at once and has an empty json. mostly they have to go sequentially but if while pulling a json from the api it can pull other json while it's waiting that is fine. I just got confused when putting the callback in a loop. what do I do with the index? i think i have seen some places that use callback inside the loop as kind of a recusive function and don't use for loops at all. simple examples would help alot thanks!

    Read the article

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