Search Results

Search found 1103 results on 45 pages for 'morgan arr allen'.

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

  • Unset array element inside a foreach loop

    - by Richard Knop
    So here is my code: <?php $arr = array(array(2 => 5), array(3 => 4), array(7 => 10)); foreach ($arr as $v) { $k = key($v); if ($k > 5) { // unset this element from $arr array } } print_r($arr); // now I would like to get the array without array(7 => 10) member As you can see, I start with an array of sinwgle key = value arrays, I loop thorugh this array and get a key of the current element (which is a single item array). I need to unset elements of the array with key higher than 5, how could I do that? I might also need to remove elements with value less than 50 or any other condition. Basically I need to be able to get a key of the current array item which is itself an array with a single item.

    Read the article

  • Array not returned correctly

    - by hp1
    I am trying to return a simple array, but I am not getting the correct result. I am getting the following arr1[0] = 1 arr1[1] = 32767 result while the result should have been arr1[0] = 1 arr1[1] = 15 Please suggest. int *sum(int a, int b){ int arr[2]; int *a1; int result = a+b; arr[0]= 1; arr[1]= result; a1 = arr; return a1; } int main(){ int *arr1 = sum(5,10); cout<<"arr1[0] = "<<arr1[0]<<endl; cout<<"arr1[1] = "<<arr1[1]<<endl; return 0; }

    Read the article

  • How can we find second maximum from array efficiently?

    - by Xinus
    Is it possible to find the second maximum number from an array of integers by traversing the array only once? As an example, I have a array of five integers from which I want to find second maximum number. Here is an attempt I gave in the interview: #define MIN -1 int main() { int max=MIN,second_max=MIN; int arr[6]={0,1,2,3,4,5}; for(int i=0;i<5;i++){ cout<<"::"<<arr[i]; } for(int i=0;i<5;i++){ if(arr[i]>max){ second_max=max; max=arr[i]; } } cout<<endl<<"Second Max:"<<second_max; int i; cin>>i; return 0; } The interviewer, however, came up with the test case int arr[6]={5,4,3,2,1,0};, which prevents it from going to the if condition the second time. I said to the interviewer that the only way would be to parse the array two times (two for loops). Does anybody have a better solution?

    Read the article

  • how to do sorting using java

    - by karthikacyr
    hi friends, I have text file with list of alphabets and numbers. I want to do sorting w.r.t this number using java. My text file looks like this: a---12347 g---65784 r---675 I read the text file and i split it now. But i dont know how to perform sorting . I am new to java. Please give me a idea. My output want to be g---65784 a---12347 r---675 Plese help me. Thanks in advance. My coding is String str = ""; BufferedReader br = new BufferedReader(new FileReader("counts.txt")); while ((str = br.readLine()) != null) { String[] get = str.split("----"); When i search the internet all suggest in the type of arrays. I tried. But no use.How to inlude the get[1] into array. int arr[]=new int[50] arr[i]=get[1]; for(int i=0;i<50000;i++){ for(int j=i+1;j<60000;j++){ if(arr[i]arr[j]){ System.out.println(arr[i]); } }

    Read the article

  • Using LINQ to filter rows of a matrix based on inclusion in an array

    - by Bob Feng
    I have a matrix, IEnumerable<IEnumerable<int>> matrix, for example: { {10,23,16,20,2,4}, {22,13,1,33,21,11 }, {7,19,31,12,6,22}, ... } and another array: int[] arr={ 10, 23, 16, 20} I want to filter the matrix on the condition that I group all rows of the matrix which contain the same number of elements from arr. That is to say the first row in the matrix {10,23,16,20,2,4} has 4 numbers from arr, this array should be grouped with the rest of the rows with 4 numbers from arr. better to use linq, thank you very much!

    Read the article

  • What is the easiest way to set the value of an entire array?

    - by Alex
    My current project requires me to fill an array based upon some other values. I know there's the shortcut: int arr[4][4] = { {0,0,0,0} , {0,0,0,0} , {0,0,0,0} , {0,0,0,0} }; But in this case, I need to fill the array after its declaration. I currently have my code formatted like this: int arr[4][4]; if(someothervariable == 1){ arr = { {1,1,1,1}, {1,2,3,4}, {2,,3,4,5}, {3,4,5,6} }; } But it won't compile. Is there a way to make use of the mentioned shortcut in my case? If not, whats the best fix available? I'd appreciate a way to set it without explicitly assigning each element? ie: arr[0][0] = ...

    Read the article

  • Data Binding to an object in C#

    - by Allen
    Objective-c/cocoa offers a form of binding where a control's properties (ie text in a textbox) can be bound to the property of an object. I am trying to duplicate this functionality in C# w/ .Net 3.5. I have created the following very simple class in the file MyClass.cs: class MyClass { private string myName; public string MyName { get { return myName; } set { myName = value; } } public MyClass() { myName = "Allen"; } } I also created a simple form with 1 textbox and 1 button. I init'd one instance of Myclass inside the form code and built the project. Using the DataSource Wizard in Vs2008, i selected to create a data source based on object, and selected the MyClass assembly. This created a datasource entity. I changed the databinding of the textbox to this datasource; however, the expected result (that the textbox's contents would be "allen") was not achieved. Further, putting text into the textbox is not updating the name property of the object. I know i'm missing something fundamental here. At some point i should have to tie my instance of the MyClass class that i initialized inside the form code to the textbox, but that hasn't occurred. Everything i've looked at online seems to gloss over using DataBinding with an object (or i'm missing the mark entirely), so any help is great appreciated. ----Edit--- Utilizing what i learned by the answers, i looked at the code generated by Visual Studio, it had the following: this.myClassBindingSource.DataSource = typeof(BindingTest.MyClass); if i comment that out and substitute : this.myClassBindingSource.DataSource = new MyClass(); i get the expected behavior. Why is the default code generated by VS like it is? Assuming this is more correct than the method that works, how should i modify my code to work within the bounds of what VS generated?

    Read the article

  • Data Binding to an object in C#

    - by Allen
    Objective-c/cocoa offers a form of binding where a control's properties (ie text in a textbox) can be bound to the property of an object. I am trying to duplicate this functionality in C# w/ .Net 3.5. I have created the following very simple class in the file MyClass.cs: class MyClass { private string myName; public string MyName { get { return myName; } set { myName = value; } } public MyClass() { myName = "Allen"; } } I also created a simple form with 1 textbox and 1 button. I init'd one instance of Myclass inside the form code and built the project. Using the DataSource Wizard in Vs2008, i selected to create a data source based on object, and selected the MyClass assembly. This created a datasource entity. I changed the databinding of the textbox to this datasource; however, the expected result (that the textbox's contents would be "allen") was not achieved. Further, putting text into the textbox is not updating the name property of the object. I know i'm missing something fundamental here. At some point i should have to tie my instance of the MyClass class that i initialized inside the form code to the textbox, but that hasn't occurred. Everything i've looked at online seems to gloss over using DataBinding with an object (or i'm missing the mark entirely), so any help is great appreciated. ----Edit--- Utilizing what i learned by the answers, i looked at the code generated by Visual Studio, it had the following: this.myClassBindingSource.DataSource = typeof(BindingTest.MyClass); if i comment that out and substitute : this.myClassBindingSource.DataSource = new MyClass(); i get the expected behavior. Why is the default code generated by VS like it is? Assuming this is more correct than the method that works, how should i modify my code to work within the bounds of what VS generated?

    Read the article

  • Find directories not containing a specific directory

    - by Morgan ARR Allen
    Been searching around for a bit and cannot find a solution for this one. I guess I'm looking for a leaf-directory by name. In this example I'd like to get a list of directories call 'modules' that do NOT have a subdirectory called module. modules/package1/modules/spackage1 modules/package1/modules/spackage2 modules/package1/modules/spackage3/modules modules/package1/modules/spackage3/modules/spackage1 modules/package2/modules/ The list I desire would contain modules/package1/modules/spackage3/modules/ modules/package2/modules/ All the directories named module that do not have a subdirectory called module I started with trying something this with no luck find . -name modules \! -exec sh -c 'find -name modules' \; -exec works on exit code, okay lets pass the count as exit code find . -name modules -exec sh -c 'exit $(find {} -name modules|grep -n ""|tail -n1|cut -d: -f1)' \; This should take the count of each subdirectory called modules and exit with it. No such love.

    Read the article

  • What is the best option for reading Java property files?

    - by Mr Morgan
    Hello I have an application which uses a servlet to read an intialization parameter from web.xml for the location of a property file. The serlvet then creates an instance of a class which stores the location of the file for other programs to read as required. This class has appropriate get and set methods. But my question concerns access to the properties: should the physical property file be read by each program as at runtime or should the properties be stored in memory instead? The properties are not currently altered at runtime but this could change? I've seen various alternative approaches but am not sure which is best. Thanks Mr Morgan

    Read the article

  • Getting the count of rows in a Java resultset

    - by Mr Morgan
    Hello Does anyone know a better way of getting the number of rows in a Java resultset returned from a MySQL database? I'm currently using this: public static int getResultSetRowCount(ResultSet resultSet) { int size = 0; try { resultSet.last(); size = resultSet.getRow(); resultSet.beforeFirst(); } catch(Exception ex) { return 0; } return size; } But am open to alternatives. The resultset returned is not going to be the total number of rows read from the database so I don;t think I can use SQL COUNT. Thanks Mr Morgan.

    Read the article

  • Use of Java constructors in persistent entities

    - by Mr Morgan
    Hello I'm new to JPA and using persistence in Java anyway and I have two questions I can't quite work out: I have generated tags as: @JoinColumn(name = "UserName", referencedColumnName = "UserName") @ManyToOne(optional = false) private User userName; @JoinColumn(name = "DatasetNo", referencedColumnName = "DatasetNo") @ManyToOne(optional = false) private Dataset datasetNo; But in one of the constructors for the class, no reference is made to columns UserName or DatasetNo whereas all other columns in the class are referenced in the constructor. Can anyone tell me why this is? Both columns UserName and DatasetNo are 'foreign keys' on the entity Visualisation which corresponds to a database table of the same name. I can't quite work out the ORM. And when using entity classes, or POJO, is it better to have class variables like: private User userName; Where an instance of a class is specified or simply the key of that class instance like: private String userName; Thanks Mr Morgan.

    Read the article

  • Solr dataimporthandler problem import data latin

    - by Alvin
    I'm using Solr 1.4 and Tomcat6. DB mysql 5.1 store data latin. when i run dataimporthandler this data = view data in solr admin error font. <doc> <str name="id">295</str> <str name="subject">Tuấn Tú</str> - ...<arr name="title"> <str>tunt721</str> </arr> </doc> True data view : <doc> <str name="id">295</str> <str name="subject">Tu?n Tú</str> - ...<arr name="title"> <str>tunt721</str> </arr> </doc> help me fix problem. Many thanks

    Read the article

  • Do I need to be worried about these SMART drive temperatures?

    - by Steve Lorimer
    I have 5 hard drives in a machine sitting in a cupboard. /dev/sda is a 500GB Seagate drive, and is the boot disk. /dev/sd{b,c,d,e} are 2TB drives in a raid6 configuration. smartctl is showing significantly higher temperatures (like ~140 degrees celsius) on the raid drives than the boot drive. Do I need to be worried? /dev/sdb and /dev/sde are new Western Digital Black drives (new=1 week) /dev/sdc and /dev/sdd are 5 year old Hitachi drives /dev/sda [SAT], Temperature_Celsius changed from 40 to 39 /dev/sdc [SAT], Temperature_Celsius changed from 142 to 146 /dev/sdc [SAT], Temperature_Celsius changed from 146 to 142 /dev/sdd [SAT], Temperature_Celsius changed from 142 to 146 /dev/sda [SAT], Airflow_Temperature_Cel changed from 61 to 62 /dev/sda [SAT], Temperature_Celsius changed from 39 to 38 /dev/sde [SAT], Temperature_Celsius changed from 107 to 108 /dev/sdb [SAT], Temperature_Celsius changed from 108 to 109 /dev/sdc [SAT], Temperature_Celsius changed from 146 to 150 /dev/sdc [SAT], Temperature_Celsius changed from 146 to 150 /dev/sda [SAT], Airflow_Temperature_Cel changed from 62 to 61 /dev/sda [SAT], Temperature_Celsius changed from 38 to 39 Update: Adding detailed drive information as per request: /dev/sda =========================== smartctl 6.0 2012-10-10 r3643 [x86_64-linux-3.9.10-100.fc17.x86_64] (local build) Copyright (C) 2002-12, Bruce Allen, Christian Franke, www.smartmontools.org === START OF INFORMATION SECTION === Model Family: Seagate Pipeline HD 5900.2 Device Model: ST3500312CS Serial Number: 5VV47HXA LU WWN Device Id: 5 000c50 02aad5ad6 Firmware Version: SC13 User Capacity: 500,107,862,016 bytes [500 GB] Sector Size: 512 bytes logical/physical Rotation Rate: 5900 rpm Device is: In smartctl database [for details use: -P show] ATA Version is: ATA8-ACS T13/1699-D revision 4 SATA Version is: SATA 2.6, 1.5 Gb/s (current: 1.5 Gb/s) Local Time is: Tue Jun 3 10:54:11 2014 EST SMART support is: Available - device has SMART capability. SMART support is: Enabled /dev/sdb =========================== smartctl 6.0 2012-10-10 r3643 [x86_64-linux-3.9.10-100.fc17.x86_64] (local build) Copyright (C) 2002-12, Bruce Allen, Christian Franke, www.smartmontools.org === START OF INFORMATION SECTION === Device Model: WDC WD2003FZEX-00Z4SA0 Serial Number: WD-WMC1F1398726 LU WWN Device Id: 5 0014ee 003b8bd25 Firmware Version: 01.01A01 User Capacity: 2,000,398,934,016 bytes [2.00 TB] Sector Sizes: 512 bytes logical, 4096 bytes physical Rotation Rate: 7200 rpm Device is: Not in smartctl database [for details use: -P showall] ATA Version is: ACS-2 (minor revision not indicated) SATA Version is: SATA 3.0, 6.0 Gb/s (current: 3.0 Gb/s) Local Time is: Tue Jun 3 10:54:11 2014 EST SMART support is: Available - device has SMART capability. SMART support is: Enabled /dev/sdc =========================== smartctl 6.0 2012-10-10 r3643 [x86_64-linux-3.9.10-100.fc17.x86_64] (local build) Copyright (C) 2002-12, Bruce Allen, Christian Franke, www.smartmontools.org === START OF INFORMATION SECTION === Model Family: Hitachi Deskstar 7K3000 Device Model: Hitachi HDS723020BLA642 Serial Number: MN1220F30WSTUD LU WWN Device Id: 5 000cca 369cc9f5d Firmware Version: MN6OA580 User Capacity: 2,000,398,934,016 bytes [2.00 TB] Sector Size: 512 bytes logical/physical Rotation Rate: 7200 rpm Device is: In smartctl database [for details use: -P show] ATA Version is: ATA8-ACS T13/1699-D revision 4 SATA Version is: SATA 2.6, 6.0 Gb/s (current: 3.0 Gb/s) Local Time is: Tue Jun 3 10:54:11 2014 EST SMART support is: Available - device has SMART capability. SMART support is: Enabled /dev/sdd =========================== smartctl 6.0 2012-10-10 r3643 [x86_64-linux-3.9.10-100.fc17.x86_64] (local build) Copyright (C) 2002-12, Bruce Allen, Christian Franke, www.smartmontools.org === START OF INFORMATION SECTION === Model Family: Hitachi Deskstar 7K3000 Device Model: Hitachi HDS723020BLA642 Serial Number: MN1220F30WST4D LU WWN Device Id: 5 000cca 369cc9f48 Firmware Version: MN6OA580 User Capacity: 2,000,398,934,016 bytes [2.00 TB] Sector Size: 512 bytes logical/physical Rotation Rate: 7200 rpm Device is: In smartctl database [for details use: -P show] ATA Version is: ATA8-ACS T13/1699-D revision 4 SATA Version is: SATA 2.6, 6.0 Gb/s (current: 1.5 Gb/s) Local Time is: Tue Jun 3 10:54:11 2014 EST SMART support is: Available - device has SMART capability. SMART support is: Enabled /dev/sde =========================== smartctl 6.0 2012-10-10 r3643 [x86_64-linux-3.9.10-100.fc17.x86_64] (local build) Copyright (C) 2002-12, Bruce Allen, Christian Franke, www.smartmontools.org === START OF INFORMATION SECTION === Device Model: WDC WD2003FZEX-00Z4SA0 Serial Number: WD-WMC1F1483782 LU WWN Device Id: 5 0014ee 3002d235c Firmware Version: 01.01A01 User Capacity: 2,000,398,934,016 bytes [2.00 TB] Sector Sizes: 512 bytes logical, 4096 bytes physical Rotation Rate: 7200 rpm Device is: Not in smartctl database [for details use: -P showall] ATA Version is: ACS-2 (minor revision not indicated) SATA Version is: SATA 3.0, 6.0 Gb/s (current: 1.5 Gb/s) Local Time is: Tue Jun 3 10:54:11 2014 EST SMART support is: Available - device has SMART capability. SMART support is: Enabled

    Read the article

  • Polymorphism and passing

    - by Tucker Morgan
    Ok i am going to try and state my question as clearly as possible, but if you have trouble understanding it please just ask for clarification, i really want to figure out how to do this. I am writing a text based RPG, and i have three class that inherit from a super class, they all have special attacks that they can preform, at the same time i have a class that holds the function which handles battles in my game. Now how do i get the unique special abilities functions for whatever role the player chooses into the battle function. Also i am using the vector.push_back method to handle how my sub classes are referenced Please help me your my only hope

    Read the article

  • Blog/CMS software with editing style like Stack Exchange

    - by Merlyn Morgan-Graham
    I have been updating a Wordpress blog lately and found the turnaround time for content creation and editing is much worse than for Stack Overflow posts. Part of this has to do with being original compositions rather than riffing off a question. But part of it is the software. I am looking for CMS/blog software that has an overall editing experience similar to Stack Overflow. The most important features I'm looking for: Inline editing (mostly) Real-time preview on the same page are all important features for speeding up data entry. Markdown support (with inline and block-level code support) Syntax hilighting The features I must maintain from my self-hosted Wordpress: Somewhat popular/supported software, with extensibility support Self hostable Will work with MySql Wordpress has plugins for all these, but they don't necessarily work together. For example I've found a few markdown-on-save plugins, but I doubt those have a chance of ever supporting inline editing or real time previews. Also the most popular syntax hilighting plugins don't support inline code blocks, and I doubt previews would work with other syntax hilighting methods. If I get a wiki/web page content creation system along with it, or somehow integrate this into GitHub (with all the features I requested) I'll accept those as side benefits :) Formed as a question: Are there any pieces of content creation software for making a blog that support an editing style like Stack Exchange and Stack Overflow? Or magic combinations of Wordpress plugins that offer the same?

    Read the article

  • Using virtual functions

    - by Tucker Morgan
    I am starting to use virtual functions, and i am programming a simple text game, my question is this, if i have a virtual function called spec_abil with in a Super class called rpg_class. If you allow the player to class what class they want to play, say a mage class, a archer class, and a warrior class, which all have their own spec_abil function. How do you write it so that the program knows which one to use depending on the chosen class.

    Read the article

  • Good Video Game User Interface Design Books/Websites?

    - by Tucker Morgan
    I having been programming games for some time, but while my teachers say that my code is good and advanced, my friends say that the interface is hard to understand and not the easiest to navigate. I want to learn how to design good user interfaces so that I can program better games, and people will have a easier time getting around. Does anyone know of any good books or websites about designing video game interfaces?

    Read the article

  • Blender multiple animations and Collada export

    - by Morgan Bengtsson
    Say I have a simple mesh in Blender, with two keyframes, like so: Then, another animation for the same mesh, also with two keyframes: Theese animations worke fine in Blender and I can switch between them in the Dopesheet, where they are called "actions": The problem arises, when i try to export this to the Collada format, for use in my game engine. The only animation/action that seems to be carried over, is the one currently associated to the mesh. Is it possible to export multiple animations/actions for the same mesh, to the Collada format?

    Read the article

  • Adding cards to a vector for computer card game

    - by Tucker Morgan
    I am writing a Card game that has a deck size of 30 cards, each one of them has to be a unique, or at least a another (new XXXX) statement in a .push_back function, into a vector. Right now my plan is to add them to a vector one at a time with four separate, depending on what deck type you choose, collections of thirty .push_back functions. If the collection of card is not up for customization, other than what one of the four suits you pick, is there a quicker way of doing this, seems kinda tedious, and something that someone would have found a better way of doing.

    Read the article

  • Strange mesh import problem with Assimp and OpenGL

    - by Morgan
    Using the assimp library for importing 3D data into an OpenGL application. I get some strange problems regarding indexing of the vertices: If I use the following code for importing vertex indices: for (unsigned int t = 0; t < mesh->mNumFaces; ++t) { const struct aiFace * face = &mesh->mFaces[t]; if (face->mNumIndices == 3) { indices->push_back(face->mIndices[0]); indices->push_back(face->mIndices[1]); indices->push_back(face->mIndices[2]); } } I get the following result: Instead, if I use the following code: for(int k = 0; k < 2 ; k++) { for (unsigned int t = 0; t < mesh->mNumFaces; ++t) { const struct aiFace * face = &mesh->mFaces[t]; if (face->mNumIndices == 3) { indices->push_back(face->mIndices[0]); indices->push_back(face->mIndices[1]); indices->push_back(face->mIndices[2]); } } } I get the correct result: Hence adding the indices twice, renders the correct result? The OpenGL buffer is populated, like so: glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices->size() * sizeof(unsigned int), indices->data(), GL_STATIC_DRAW); And rendered as follows: glDrawElements(GL_TRIANGLES, vertexCount*3, GL_UNSIGNED_INT, indices->data());

    Read the article

  • Is an 'if password == XXXXXXX' enough for minimum security?

    - by Morgan Herlocker
    If I create a login for an app that has middle to low security risk (in other words, its not a banking app or anything), is it acceptable for me to verify a password entered by the user by just saying something like: if(enteredPassword == verifiedPassword) SendToRestrictedArea(); else DisplayPasswordUnknownMessage(); It seems to easy to be effective, but I certainly would not mind if that was all that was required. Is a simple check on username/password combo enough? Update: The particular project happens to be a web service, the verification is entirely server side, and it is not open-source. Does the domain change how you would deal with this?

    Read the article

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