Search Results

Search found 581 results on 24 pages for 'iterating'.

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

  • Does a HashMap retain the order of its elements on the next read if it is constructed as a LinkedHas

    - by javanix
    Suppose I have a Java method that returns a HashMap object. Because a LinkedHashMap is a subclass of HashMap, I can return a LinkedHashMap from this method just fine. On the next "read" action (no adding/removing/modifying of K/V pairs), would iterating over the keys of the resulting method (which returns a HashMap) go in the same order as the originating LinkedHashMap, even though the HashMap lacks the key links?

    Read the article

  • how do I initialize a float to its max/min value?

    - by Faken
    How do I hard code an absolute maximum or minimum value for a float or double? I want to search out the max/min of an array by simply iterating through and catching the largest. There are also positive and negative infinity for floats, should I use those instead? If so, how do I denote that in my code?

    Read the article

  • std::list or std::multimap

    - by Tamir
    Hey, I right now have a list of a struct that I made, I sort this list everytime I add a new object, using the std::list sort method. I want to know what would be faster, using a std::multimap for this or std::list, since I'm iterating the whole list every frame (I am making a game). I would like to hear your opinion, for what should I use for this incident.

    Read the article

  • How can I access x:Name from Code Behind?

    - by viky
    I have a datagrid in which I am using DataGridTemplateColumn and DataGridTextColumn. I want to access these columns at runtime so I have assigned x:Name property to them. But I was not getting that value in code behind, so I looked for DataGrid and then read objects by iterating through DataGrid.Columns. How can I read x:Name property from that object in C#? I need this to perform some specific operations with particular columns at runtime.

    Read the article

  • Enumerator problem, Any way to avoid two loops?

    - by pug
    I have a third party api, which has a class that returns an enumerator for different items in the class. I need to remove an item in that enumerator, so I cannot use "for each". Only option I can think of is to get the count by iterating over the enum and then run a normal for loop to remove the items. Anyone know of a way to avoid the two loops? Thanks

    Read the article

  • Design pattern for adding / removing elements

    - by de3
    Wikipedia's definition for Iterator pattern design: the Iterator pattern is a design pattern in which iterators are used to access the elements of an aggregate object sequentially without exposing its underlying implementation. Iterator interface in java provides the following methods hasNext() next() remove() Is there a pattern design, or a java interface for inserting / deleting elements, and getting length of the aggregate object, in addition to iterating them? I know remove() is an optional method that can be used once per call to next(), but I am implementing a circular FIFO array and need a method delete() independent of iterator's next().

    Read the article

  • Appending a prefix when using join in Perl

    - by syker
    I have an array of strings that I would like to use the join function on. However, I would like to prefix each string with the same string. Can I do this in one line as opposed to iterating through the array first and changing each value before using join?

    Read the article

  • Query a List of List of Items in LINQ c#

    - by call me Steve
    I am a bit new to LINQ, here is my problem. I have a List of List of Items I like to get the Items which are present in only one List (and if I could get the List in which they are without re-iterating through the "list of list" that would be great). I am trying without success to use the Aggregate / Except / Group keywords in the Linq query but nothing close to a solution so far.

    Read the article

  • Will the Order of my Associative Array be maintained from PHP to Javascript?

    - by Colin
    In PHP I'm running a mysql_query that has an ORDER BY clause. I'm then iterating through the results to build an associative array, with the row_id as the key. Then, I'm calling json_encode on that array and outputting the result. This page is loaded with AJAX, and defined in a Javascript variable. When I iterate through that Javascript variable, will I still have the order that was returned from the mysql_query?

    Read the article

  • I cant able to remove a row from a table while running through a loop

    - by Vibin Jith
    I am iterating through the table rows . if the row row is null I just want to remove the row. it shows an error Public Sub RemoveBlankRow(ByVal MyDataTable As DataTable) Try Dim MyRowStr As String = String.Empty For Each MyRow As DataRow In MyDataTable.Rows MyRowStr = "" For Each MyCellText As Object In MyRow.ItemArray MyRowStr = MyRowStr + MyCellText.ToString Next MyRowStr = Replace(MyRowStr, "0", " ") MyRowStr = Replace(MyRowStr, ".", " ") If MyRowStr.Trim = String.Empty Then MyDataTable.Rows.Remove(MyRow) End If Next Catch ex As Exception End Try End Sub How to overcome this issue?

    Read the article

  • Some menu customisation in Silverstripe

    - by alienv
    1) i need set different class name for every menu item, based on a menu row (iterating, i need just a number) <% control Menu(1) %> <div class="mainmenu-item-$MenuItemRow"><a href="$Link">$MenuTitle</a></div> <% end_control %> 2) is there a simple way to create an small second menu ?

    Read the article

  • Link Labels c# - displaying a list of them

    - by tom
    I am trying to add a list of linked lables to a listview. I amd doing so like this foreach (String s in values) { LinkLabel label = new LinkLabel(); label.Text = s; txtBox.Controls.Add(label); } } It keeps adding just one item to the listbox even tho there are more. Any ideas? ps) i can tell there are more items from adding a breakbpoint and using console.writeline when iterating Thanks

    Read the article

  • Reading ini file in C#

    - by pm_2
    I am trying to read an ini file that has the following format: SETTING=VALUE SETTING2=VALUE2 I currently have the following code: string cache = sr.ReadToEnd(); string[] splitCache = cache.Split(new string[] {"\n", "\r\n"}, StringSplitOptions.RemoveEmptyEntries); Which gives me a list of settings, however, what I would like to do is read this into a dictionary. My question is, is there a way to do this without iterating through the entire array and manually populating the dictionary?

    Read the article

  • How Can I Get a TextPointer from a mouse click in a FlowDocument

    - by Bear
    I would like to get the word that a user has clicked on in a FlowDocument. I am currently adding an event handler to every Run in the document and iterating through the TextPointers in the Run that was clicked, calling GetCharacterRect() on each one and checking if the rectangle contains the point. However, when the click occurs near the end of a long Run this takes 10 seconds. Is there any more efficient method?

    Read the article

  • How to initiate JavaScript Callback with MVC2 using RenderAction

    - by Zacho
    I am building a dashboard where I am iterating through a list of controls to render, and I need to initiate a general callback both after each control and after they are all completed. I was curious what the best way to handle this is. I can get the control specific callback fired off by placing myUserControlCallback(); in the user control itself. I'm just not sure how to run something like allControlsRendered();. Any ideas?

    Read the article

  • removing elements incrementally from a list

    - by Javier
    Dear all, I've a list of float numbers and I would like to delete incrementally a set of elements in a given range of indexes, sth. like: for j in range(beginIndex, endIndex+1): print ("remove [%d] => val: %g" % (j, myList[j])) del myList[j] However, since I'm iterating over the same list, the indexes (range) are not valid any more for the new list. Does anybody has some suggestions on how to delete the elements properly? Best wishes

    Read the article

  • Easy way to keep counting up infinitely

    - by Andrew Alexander
    What's a good way to keep counting up infinitely? I'm trying to write a condition that will keep going until there's no value in a database, so it's going to iterate from 0, up to theoretically infinity (inside a try block, of course). How would I count upwards infinitely? Or should I use something else? I am looking for something similar to i++ in other languages, where it keeps iterating until failure.

    Read the article

  • Reflection: different ways to retrieve property value

    - by jules
    I'm retrieving an IEnumerable list of properties via following code: BindingFlags bindingFlag = BindingFlags.Instance | BindingFlags.Public; var dataProperties = typeof(myParentObject).GetProperties(bindingFlag); Then I'm iterating through the list and retrieving the value for each property. I've come across two different approaches to doing this, and just wondered what the difference is between them: 1) object propertyValue = property.GetGetMethod().Invoke(myObject, null); 2) object propertValue = property.GetValue(myObject, null)

    Read the article

  • Is there a way to efficiently yield every file in a directory containing millions of files?

    - by Josh Smeaton
    I'm aware of os.listdir, but as far as I can gather, that gets all the filenames in a directory into memory, and then returns the list. What I want, is a way to yield a filename, work on it, and then yield the next one, without reading them all into memory. Is there any way to do this? I worry about the case where filenames change, new files are added, and files are deleted using such a method. Some iterators prevent you from modifying the collection during iteration, essentially by taking a snapshot of the state of the collection at the beginning, and comparing that state on each move operation. If there is an iterator capable of yielding filenames from a path, does it raise an error if there are filesystem changes (add, remove, rename files within the iterated directory) which modify the collection? There could potentially be a few cases that could cause the iterator to fail, and it all depends on how the iterator maintains state. Using S.Lotts example: filea.txt fileb.txt filec.txt Iterator yields filea.txt. During processing, filea.txt is renamed to filey.txt and fileb.txt is renamed to filez.txt. When the iterator attempts to get the next file, if it were to use the filename filea.txt to find it's current position in order to find the next file and filea.txt is not there, what would happen? It may not be able to recover it's position in the collection. Similarly, if the iterator were to fetch fileb.txt when yielding filea.txt, it could look up the position of fileb.txt, fail, and produce an error. If the iterator instead was able to somehow maintain an index dir.get_file(0), then maintaining positional state would not be affected, but some files could be missed, as their indexes could be moved to an index 'behind' the iterator. This is all theoretical of course, since there appears to be no built-in (python) way of iterating over the files in a directory. There are some great answers below, however, that solve the problem by using queues and notifications. Edit: The OS of concern is Redhat. My use case is this: Process A is continuously writing files to a storage location. Process B (the one I'm writing), will be iterating over these files, doing some processing based on the filename, and moving the files to another location. Edit: Definition of valid: Adjective 1. Well grounded or justifiable, pertinent. (Sorry S.Lott, I couldn't resist). I've edited the paragraph in question above.

    Read the article

  • Using json_encode on objects in PHP

    - by Alan
    Hi, I'm trying to output lists of objects as json and would like to know if there's a way to make objects usable to json_encode? The code I've got looks something like $related = $user->getRelatedUsers(); echo json_encode($related); Right now, I'm just iterating through the array of users and individually exporting them into arrays for json_encode to turn into usable json for me. I've already tried making the objects iterable, but json_encode just seems to skip them anyway.

    Read the article

  • Combining foreach and using

    - by apoorv020
    I'm iterating over a ManageObjectCollection.( which is part of WMI interface). However the important thing is, the following line of code. : foreach (ManagementObject result in results) { //code here } The point is that ManageObject also implements IDisposable, so I would like to put "result" variable in a using block. Any idea on how to do this, without getting too weird or complex?

    Read the article

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