list

List sorting and ordering problem...

So I've resigned myself to not being able to use the order of a List reliably because hibernate reverses it and everyone says don't do it, so I've added a field to my class as position. I have: @Entity class Procedure { ... int procedureId; List tasks; ... } @Entity class Task { ... int taskId; int position; } Now I don't know how ...

I can't find the logic error in this bubble sort code

I'm attempting to do a simple bubble sort code to get familiar with list/string manip & method use, but for some reason, when I attempt to iterate through each value in the list to remove white space and values that are non ints, it skips some. I haven't even gotten to the bubble sorting part.. #test data: 45,5j, f,e,s , , , 45,q, ...

Benefit of slist over vector?

What I need is just a dynamically growing array. I don't need random access, and I always insert to the end and read it from the beginning to the end. slist seems to be the first choice, because it provides just enough of what I need. However, I can't tell what benefit I get by using slist instead of vector. Besides, several materials I...

Flex 3 - how to select an item in the list as default ?

how to select an item in the list as default default selected item say of index 0 I tried stuff like this -- listid.selectedIndex = somevalueinmyprogram - 1; // 0 but when i debug this i get _selectedIndex = 0 selectedIndex = -1 and default value is not selected why so? [i have already checked for the obvious that somevaluef...

Simple PHP Condition help: if($Var1 = in list($List) and $Cond2) - Is this posslbe?

Hey is this a possible funtion? I need to check if a variable is existent in a list of ones I need to check against and also that cond2 is true eg if($row['name'] == ("1" || "2" || "3") && $Cond2){ doThis(); } It's not working for me and all I changed in the copy paste was my list and the variable names ...

Split string, convert ToList<int>() in one line...

I have a string has numbers string sNumbers = "1,2,3,4,5"; Split it then Convert To List sNumbers.Split( new[] { ',' } ).ToList<int>(); How can i convert string array to integer list? So i need to convert string[] to IEnumerable ... ...

What is the underlying data structure for Python lists?

What is the typical underlying data structure used to implement Python's built-in list data type? ...

Check string to see if a string within a a string array occurs within it

Hi , I have a generic list of string: List listOfString = new List(); I then add 4 strings to this list: listOfString .Add("test1"); listOfString .Add("test2"); listOfString .Add("test3"); listOfString .Add("test4"); I want to check check a string variable if it contains any element within my string a...

Sorting a tuple that contains lists

I have a similar question to this one but instead my tuple contains lists, as follows: mytuple = ( ["tomato", 3], ["say", 2], ["say", 5], ["I", 4], ["you", 1], ["tomato", 6], ) What's the most efficient way of sorting this? ...

List<? extends myType>

I have a Java question about generics. I declared a generic list: List<? extends MyType> listOfMyType; Then in some method I try instantiate and add items to that list: listOfMyType = new ArrayList<MyType>(); listOfMyType.add(myTypeInstance); Where myTypeInstance is just an object of type "MyType"; it won't compile. It says: ...

Is there a way in Python to index a list of containers (tuples, lists, dictionaries) by an element of a container?

I have been poking around for a recipe / example to index a list of tuples without taking a modification of the decorate, sort, undecorate approach. For example: l=[(a,b,c),(x,c,b),(z,c,b),(z,c,d),(a,d,d),(x,d,c) . . .] The approach I have been using is to build a dictionary using defaultdict of the second element from collections...

Nested UL/LI not shown

<ul id="nav"> <div id="navspacer" /> <li class="button" style="width: 109px;"></li> <li class="button" style="width: 86px;"> <img alt="Webdesign" src="images/digifolio_10.jpg"/> <ul> <li>a</li> <li>b</li> <li>c</li> </ul> </li> </ul> <div id="main"> content </div> li.button has a fix...

Clearing a Collection of Collections - clear every item first, or just clear all at once?

Suppose I have a Collection of some kind that itself contains Collections; e.g., Dictionary(Of String, List(Of MyClass)). If I want to clear the Collection entirely, does it make any sense to clear every individual child collection before clearing the parent collection, like so: For Each ListDef As KeyValuePair(Of String, List(Of MyClas...

How decide what to put in a MOSS site template/definition

Hi When deciding on what elements to include in a MOSS site definition, i.e. lists, libraries etc. is there a rule of thumb on how best to make this decision? Would appreciate anyones suggestions. All the best ...

Creating lists of lists in a pythonic way

I'm using a list of lists to store a matrix in python. I tried to initialise a 2x3 Zero matrix as follows. mat=[[0]*2]*3 However, when I change the value of one of the items in the matrix, it changes the value of that entry in every row, since the id of each row in mat is the same. For example, after assigning mat[0][0]=1 mat is [[...

Array to List -- Cannot make AddRange(IEnumerable) work...

I'm sorry about the naive question. I have the following: public Array Values { get; set; } public List<object> CategoriesToList() { List<object> vals = new List<object>(); vals.AddRange(this.Values); return vals; } But this won't work because I can't type the array. Is there any way to easily fix the code above or, in g...

python - match on array return value

I want to do a functional like pattern match to get the first two elements, and then the rest of an array return value. For example, assume that perms(x) returns a list of values, and I want to do this: seq=perms(x) a = seq[0] b = seq[1] rest = seq[2:] Of course I can shorten to: [a,b] = seq[0:2] rest = seq[2:] Can I use some not...

C# Help: Sorting a List of Objects in C#

public class CarSpecs { public CarSpecs() { } private String _CarName; public String CarName { get { return _CarName; } set { _CarName = value; } } private String _CarMaker; public String CarMaker { get { return _CarMaker;} set { _CarMaker = value; } } p...

Copying a portion of a list to a new list.

Hey all. Is there a way to copy only a portion of a single (or better yet, a two) dimensional list of strings into a new temporary list of strings? ...

Checking to See if a List Exists Within Another Lists?

Okay I'm trying to go for a more pythonic method of doing things. How can i do the following: required_values = ['A','B','C'] some_map = {'A' : 1, 'B' : 2, 'C' : 3, 'D' : 4} for required_value in required_values: if not required_value in some_map: print 'It Doesnt Exists' return False return True I looked at the ...