Create a Binary search tree by extending either Vector or Arraylist and create a method that enters elements and preserves partial ordering property - vector

Populate and depopulate to show how it works. Check for empty and size of each structure and implement methods that perform preorderd, inordered and postordered traversels.
I am not sure on where to start. If anyone could do the entire code that would be greate. Thank you in advance.

Related

What are differences between index and item method of QStandardItemModel?

My friends, Could you please explain the concept of these methods to me? Normally, when I get a data I would use 'index' to refer to items in a model and specify roles via data attribute. I came across 'item' method today and the explanation of this method is "Returns the item for the given row and column if one has been set; otherwise returns 0." What are differences from 'index'+'data' method? Is it just a shortcut?
This is the documentation of 'item' method.
https://doc.qt.io/qt-5/qstandarditemmodel.html#item
Alternatively, this is the documentation of 'index' method.
https://doc.qt.io/qt-5/qstandarditemmodel.html#index
I'll try my best to explain it.
The item is like the actual widget you see in the view (it's not actually a widget, but I think it's a good way to think about it). It's what the user is actually seeing.
The index is more "behind the scenes." It's like a pointer to a position in the model.
An item can exist without an index. But a valid index cannot exist without an item. The item only associates with an index when it is put into a model. Otherwise, it's just an item that no one can look at.
Take an array as an example... It contains multiple "items". You specify which item from the array you want by providing a number, aka the index. Simply put, the index only exists when it is associated with an item in the array. But the item can exist outside of the array and be it's own thing without an index.
The QModelIndex was created to be a lightweight way to reference items in a model. Similar to the way you can use a number to represent an object stored in an array.

create objects dynamically according database values

I have a Flex project. I want to dynamically create mx.controls.Image objects and add them to the display. However, the number of images and it properties deponds on the value stored in a database. Hence, I have to connect to the database,read the values for data table, then create objects dynamically according the values.
Then, I wonder if this is possible and how to do this.
Thanks in advance.
Felix
Just try declaring a variable as *.
Like var any:*; And check always for null. So it will take any type of value.
Hope it will help.

AdvancedDataGrid (grouping) quick jump to row

I have a problem with the AdvancedDataGrid widget. When the dataProvider is an ArrayCollection (of arrays), the nth array (within the collection) is also the nth row within the grid, and I can jump and display the i-th row by scripting
adg.selectedIndex = i;
adg.scrollToIndex(i);
now, when I add a Grouping, the dataProvider ends up being a GroupingCollection2, and now the index in the dataprovider's source does not correspond to the index in the adg anymore (which is understandable, because it's being grouped).
How can I select and display a row in grouped data efficiently? Currently, I have to traverse the adg and compare each found item with its data attributes in order to find the correct index of the row within the adg, and jump to it like above. This process is very slow. Any thoughts?
edited later:
We already used a caching object as Shaun suggests, but it still didn't compensate for the search times. In order to fully construct a sorting of a list of things (which this problem equates to, as the list is completely reordered by the grouping), you always have to know the entire set. In the end we didn't solve that problem. The project is over now. I will accept Shaun's answer if no one knows a better way in three days.
Depending on what values your comparing against you can store the objects in a dictionary with the lookup using the property/properties that would be searched for, this way you have a constant time look-up for the object (no need to look at every single item). Say for example your using a property called id on an object then you can create an AS object like
var idLookup:Object = {};
for(myObject in objects)
idLookup[myObject.id] = myObject;
//Say you want multiple properties
//idLookup[myObject.id]={};
//idLookup[myObject.id][myObject.otherProp] = myObject;
now say the user types in an id you go into the idLookup object at that id property and retrieve the object:
var myObject:Object = idLookup[userInput.text];
myAdg.expandItem(myObject, true);
now when you want to get an object by id you can just do
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/controls/AdvancedDataGrid.html#expandItem()
I haven't done any thorough testing of this directly, but use a similar concept for doing quick look-ups for advanced filtering. Let me know if this helps at all or is going in the wrong direction. Also if you could clarify a bit more in terms of what types/number of values you need to lookup and if there's the possibility for multiple matches etc. I may be able to provide a better answer.
Good luck,
Shaun

Change a value in a dynamically generated drop down list

Ok so I have drop down list connected to a datasource, and I need to change 2 or 3 of the values before they are displayed and I'm just having trouble figuring out what to do. I'm assuming I setup some kind of loop to check the values, but thats all I can figure. Does anybody have any general suggestions or resources they know that I can look up? Thanks.
You need to do your processing before you bind the datasource. So for example, create a dataset of results or arraylist, process the results changing your values and then bind to your dataset/arraylist.
You'll need to be more specific about what you are binding to and how you want to process for me to be more specific..
See link at http://www.c-sharpcorner.com/uploadfile/sd_patel/dropdownlistbox11222005064123am/dropdownlistbox.aspx

Good way to rename fields in Actionscript array?

Should be easy but google couldn't give me a straight answer. I have an array. The fields in the array have underscores that I would like to remove e.g. "Column_1" to "Column 1". Does anyone know a good way to do this without looping through the whole array and rebuilding it anew? I didn't see any methods in the reference that would make this easy. thx
Depending on where you are using this Array, you could use the labelFunction to format the data before presenting it. It is present in Lists, DataGrids and Trees.
But you'd only need this if you have a very large data and wouldn't want to loop over all the records before showing them. A labelFunction would "reprocess" the label everytime before it's presented.
Flex 3 has built in refactoring
Edit... I may have misunderstood..
If you want to format the data in the array just loop through it and use regex to remove the underscores... or you can modify your query which grabs the data (if it is populated from a query)

Resources