Does arraylist add operation automatically add to the front of the list or end? - arraylist

The Java documentation for arraylist states: This method inserts the specified element E at the specified position in this list. It shifts the element currently at that position (if any) and any subsequent elements to the right (will add one to their indices).
Does this mean arraylist add() method by default add the element to the front?

Related

Does DetailsList expose a callback to add more items to the list(pagination)

I have a scenario where there are total of 150 items that we want to render, but server returns set of items - say 30 at a time.
We want to use DetailsList, however, we did not find any prop that can be used to update (add to) the list of items when user scrolls to the bottom of present list.
I see that DetailsList handles UI virtualization, however it seems we need to pass the entire set of items at the beginning only.

Removing Textbox and DateTimePicker in a Panel

I have a code that deletes the textbox and datetimepicker i create in a panel... delete code is working for all the TEXTBOX but when its time to delete the datetimepickers it does not delete all the datetimepicker.
Example: there are 4 textbox and 4 datetimepickers when it runs the code the panel will delete all 4 textbox but deletes 2 datetiepickes only. I really cant find out what is wrong. Please help me... Thanks!
code is here:
For Each ctrlTxt As TextBox In panelGroupDependent.Controls.OfType(Of TextBox)()
ctrlTxt.Dispose()
Next
For Each ctrlDtp As DateTimePicker In panelGroupDependent.Controls.OfType(Of DateTimePicker)()
ctrlDtp.Dispose()
Next
As it stands, you are modifying a collection as you are enumerating it, which is not allowed. A For Each loop enumerates a collection so you are not allowed to add or remove items within the loop. When you dispose a control, it is removed from its parent container and thus you are modifying the Controls collection of that parent.
The OfType method doesn't actually generate a new collection of items but rather enumerates the collection it's called on and yields the items of the specified type one by one. As such, enumerating the result of OfType means enumerating the source collection at the same time.
By calling ToArray, you complete the enumeration of the source collection first and populate an array with the items of the specified type, then enumerate that array using the For Each loop. Disposing the controls has no effect on the array so there's no issue.
For Each ctrlTxt In panelGroupDependent.Controls.
OfType(Of TextBox)().
ToArray()
ctrlTxt.Dispose()
Next
For Each ctrlDtp In panelGroupDependent.Controls.
OfType(Of DateTimePicker)().
ToArray()
ctrlDtp.Dispose()
Next
Note that there is also no need to declare the type of the loop control variables as it can be inferred.

How to ask user to snap on a vertex of a line element (in the ILocateCommandEvents_Accept handler) of Microstation VBA

I know how to write a VBA macro in Microstation that will ask the user to select an element:
Sub Create2DCrossLines()
' Set error handler
On Error GoTo ErrorHandler
' Let the user select the bank elements himself
Call CommandState.StartLocate(New clsSelectBanksLCE)
Exit Sub
ErrorHandler:
Call ReportError("Create2dCrossLines")
End Sub
clsSelectBanksLCE uses ILocateCommandEvents for managing that part of the logic. So the user can select a LineElement for example and when the Accept event is fired it runs an action:
Private Sub ILocateCommandEvents_Accept(ByVal Element As Element, _
Point As Point3d, _
ByVal View As View)
In my particular case we track selecting element 1 and then element 2 and once both elements are selected it proceeds. This is all fine.
My problem is this: after I accept the first element, and before proceeding to select the next (ie: in the Accept handler) I want to get the user to snap on to two vertices of the line element.
I need to know which part of the line element they want to process. I can't work out how to do this. In AutoCAD you can use GetPoint.
So I want to ask them to snap on to the first vertex on this line element, then snap onto the end vertex. After this can we move on to select the second element.
Update
I have just stumbled over this article. I notice it says:
Once the user has accepted an element, we should start another class that implements IPrimitiveCommandEvents to obtain a target datapoint. Finally, compute the offset from the supplied locate datapoint to the target datapoint and move the element.
It seems what I want but I just am not clear on the right order. At the moment I have:
ILocateCommandEvents_Start This begins the location process.
ILocateCommandEvents_LocateFilter. If the element is a LineElement, then it
assigns m_Element1 and the second event fired assigns m_Element2.
ILocateCommandEvents_Accept If both the variables are not nothing it runs the main process.
See my dilemma? It sounds like I need to:
Run one instance of ILocateCommandEvents to select one element only.
Then run one instance of IPrimitiveCommandEvents to get the first snap point.
Then run another instance of IPrimitiveCommandEvents to get the second snap point.
Then run another instance of ILocateCommandEvents to get the second element.
Finally, once the second element is accepted, perform my processing.
That is how I understand I need to do it. Or, can I use my one ILocateCommandEvents class that currently gets the user to choose two elements?
Guidance appreciated.
Update
I got it to work by following the above logic. That article really helped. The only issue I have now is that I need to draw a rubber band. But that is a separate question.
As mentioned in this article:
Once the user has accepted an element, we should start another class that implements IPrimitiveCommandEvents to obtain a target datapoint. Finally, compute the offset from the supplied locate datapoint to the target datapoint and move the element.
The link also provides example code on how to use the IPrimitiveCommandEvents event class.

Searchable List of Different Datatypes

I'm working on an application that displays different customized form controls to users depending on the data type of the value that needs to be displayed. So, for example, a Boolean value appears as a check box. However, there are some types that I do not want to display. As the form and controls are generated at run-time, I need to build some logic that prevents these unsupported types from appearing.
Here's what I've tried to accomplish this:
I have a List unsupportedTypes As List(Of Type) that I fill with the types I want to exclude:
unsupportedTypes.Add(GetType(System.Drawing.Color))
'more types removed for brevity
This complies, but throws a null reference exception at the above line, which I suppose makes sense since there isn't any thing to put into the list. However, trying to create a color
unsupportedTypes.Add(GetType(New System.Drawing.Color))
will not even compile.
How can I build a list (or other collection) of different data types that I can search?
This compiles and works at runtime, so i don't really understand your issue:
Dim unsupportedTypes As New List(Of Type) ' New prevents a null reference exception
unsupportedTypes.Add(GetType(Drawing.Color))
Since you have mentioned i have a list: unsupportedTypes As List(Of Type), is it possible that you have forgotten to initialize it?

iOS UI Automation - how to find a row within a tableView

I want to use UI Automation to look through a tableView and find the row that matches a certain label, and select that row. Is there a way to do this with UIAutomation?
UIAutomation framework uses the UI element hierarchy to locate specific element on which you want to perform an automated action. Once you locate the table view from the UI element hierarchy of your app, you can call the function .cells().firstWithName(The value of the name property of that cell).tap(). This function will search all the rows of the table and tap on the first row with the name that matches the name string that you have passed as the argument. There is also a function .withName(The value of the name property of that cell) that returns an array of row objects all of which contain the name that matches the name string that you have passed as the argument.
p.s. The above mentioned functions only work with the name property.
Hope this helps!