Vote count: 0 I understand that ArrayList's are fastest for searching (O(1) vs. O(n)) and LinkedList's are fastest for inserting & deleting (O(1) vs. O(n)). My question is, if using a combination of these two, what is the optimal method to check many lists (>2) for common elements? Current Method Using three lists and an iterative method: out: for(int a = 0; a < list1.size(); a++) { for(int b = 0; b < list2.size(); b++) { for(int c = 0; c < list3.size(); c++) { if(list1.get(a) == list2.get(b) &&...
ادامه مطلبVote count: 0 I am trying to couple wx.ListBox with wx.combo.Comboctrl. A sample code is below. For some reason, the items in the ListBox are not clickable/selectable. I wonder how I can make it work. Thanks! import wx, wx.combo class MainFrame(wx.Frame): def __init__(self, parent): wx.Frame.__init__(self, parent, title="", size=(300, 100)) gbs = wx.GridBagSizer() ComboCtrlBox = wx.combo.ComboCtrl(self) ComboCtrlPopup = ListBoxComboPopup() ComboCtrlBox.SetPopupControl(ComboCtrlPopup) ComboCtrlPo...
ادامه مطلبVote count: 0 I have two separate lists from db as : List lstId which has values 0,1,2,… List lstnaname which has values “a”,”b”,c” I want to combine these two lists which don’t have any common column . My expected output would be List out Out[0] = {0,”a”} Out[1] = {1,”b”} I tried using concat in linq but it just add the listA to listB. Join clause doesn’t work because there are no common fields. How would I achieve it? asked 24 secs agouser1400915 Let's block ads!...
ادامه مطلبVote count: 0 So, I've been struggling on this for a while and have searched on here for hours without finding anything that really helped. I have a custom class Streak. When the user creates a new Streak in my Main Activity, I want for that streak to be added to a list of total streaks, which I would then access from an AllStreaks activity. I have tried using Gson, but received errors. What I have below is working for the time being, but since my global variable has to be declared as new. I don...
ادامه مطلبVote count: 0 I have two separate arrayLists. For example: array1 = [[1 2 3 4 5 6]] array2 = [[3 7 8 9 10 11 16]] I want to have an arraylist like below: arrayResult = [[1 2 3 7 8 9 10 11 16]] There is a mutual variable on two arraylists and I want to have the first part of array1 + second part of array2 in a new arraylist. asked 43 secs agoEbola Let's block ads!...
ادامه مطلبVote count: 0 I have Entity User class User{ private Long id; private String Name; private List someClass; } And Entity SomeClass class SomeClass{ private Long id; private String Name; } I have two object User user1 and user2 user1.getSomeClass().size() == 5; user2.getSomeClass().size() == 5; I need to compare all the elements user1.someClass and user2.someClass but I do not understand how to do it. how to match any element to which refers. I have bad English but I'll try to explain. I create th...
ادامه مطلبVote count: 0 C++ code: #include #include #include #include #include using namespace std; #define FILE_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) int main() { timeval tv1, tv2, tv3, tve; gettimeofday(&tv1, 0); int size = 0x1000000; int fd = open("data", O_RDWR | O_CREAT | O_TRUNC, FILE_MODE); ftruncate(fd, size); char *data = (char *) mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); for(int i = 0; i < size; i++) { data[i] = 'S'; } munmap(data, size); close(fd); gettimeofday(&tv2, 0); ...
ادامه مطلبVote count: 0 I was wondering how I could calculate the average of a specific category via Python? I have a csv file called demo.csv import pandas as pd import numpy as np #loading the data into data frame X = pd.read_csv('demo.csv') the two columns of interest are the "Category" and "Totals" column: Category Totals estimates 2 2777 0.43 4 1003 0.26 4 3473 0.65 4 2638 0.17 1 2855 0.74 0 2196 0.13 0 2630 0.91 2 2714 0.39 3 2472 0.51 0 1090 0.12 I'm interested in finding the average for the Totals...
ادامه مطلبVote count: 0 I have some problems understanding how python/numpy is casting array shapes when comparing to an empty list - which as far as I understand - is an implicit (element wise) comparison with False. In the following example the shape decreases by one in the last dimension, if it is not greater than 1. z = N.zeros((2,2,1)) z == [] >> array([], shape=(2, 2, 0), dtype=bool) z2 = N.zeros((2,2,2)) z2 ==[] >> False If, however, I compare with False directly, I get the expected output. z = N.z...
ادامه مطلبVote count: 0 I am using AWS CLI to get the list of AMI's created by specific owner however I want to get the creation date of the AMI along with the size of the AMI The command I am using is below. ec2-describe-images --filter "is-public=false" --filter "architecture=x86_64" --filter "owner-id=xxxxxxx" Please guide me. asked 23 secs agoNarendra522 Let's block ads!...
ادامه مطلبVote count: 0 So I'm making a code where it asks the user to to swap two places on the list until the list is from smallest to biggest. So it should look like this: Hello: Your current list is [6, 7, 8, 2 , 9, 10, 12, 15, 16, 17] Please pick your first location -> 4 Please pick your second location -> 2 Your new list is [6, 2, 8, 7 , 9, 10, 12, 15, 16, 17] I've gotten to this part but I am currently unable to figure out how to get the USER to do the sorting and not the code. Your list is not sor...
ادامه مطلبVote count: 0 I have two lists that I want to combine for csv output. alist = ['a', 'b', 'c'] blist = ['d', 'e', 'f'] However, I want the output for the csv to format like this: clist = ['a', 'b', 'c', 'd' 'e' 'f'] such that the last entry extended of the list contains the list of "blist", but will not be comma separated. Unfortunately, what I have been trying instead gives me: clist = ['a', 'b', 'c', 'def'] asked 1 min agoArca Let's block ads!...
ادامه مطلبVote count: 0 I have a dashboard which contains many formulas that change depending on the value on the drop down list. Is there any macro which can run a loop for all the values in the drop down list, copy the contents of the entire sheet and paste it into a new workbook? asked 31 secs agoadithya viswanathan Let's block ads!...
ادامه مطلبVote count: 0 I have a barcode generator that takes information stored in a database and generates a barcode from a databound checkboxlist selection. There are different check boxes, the user checks the boxes of the items they want and enter a universal total. protected void btnGenerate_Click(object sender, EventArgs e) { int n; int i = Int32.Parse(BatchNumText.Text); for (n = 1; n...
ادامه مطلبVote count: 0 I am trying to rotate a List of items to the right by the specified numbers of places without using LINQ, how am I able to do this? I think I am not understanding how to approach/solve this problem in particular. Here's what I have tried so far. public void Test(List items, int places) { items.RemoveAt(places); items.Add(places); } asked 1 min agoZerox Let's block ads!...
ادامه مطلبVote count: 0 I want to create a array of object to mongoDb using expressJs (restful API ) . I have a array like this : [ { name: 'java', _id: 578c81ea7d5940501419e819, articles: [] }, { name: 'C#', _id: 578c81ea7d5940501419e81a, articles: [] }, { name: 'C++', _id: 578c81ea7d5940501419e81b, articles: [] }, { name: 'cloud', _id: 578c81ea7d5940501419e81c, articles: [] } ] How can I insert this array to mongoDB by only one function ? thanks for any help . asked just nowTrần Dương Let's block ads!...
ادامه مطلبVote count: 0 I am having some difficulty coming up with an efficient way of taking a list of strings and converting it to tuple pairs. I have a list similar to: listOfNames = ['red-l','blue-l','green-s','red-s','blue-s'] Every color in this example (red, blue, and green) has either a '-l' or '-s' entry or both. I need to convert this list of strings into tuple pairs such as: tupleOfNames = [('red-l','red-s'),(None,'green-s'),('blue-l','blue-s')] I think regular expressions is needed but I am no...
ادامه مطلبVote count: 0 I have some imports : gi.require_version('Gtk', '3.0') from gi.repository import Gtk from gi.repository import Gdk, GdkPixBuf An error (maybe 2) is raised : WAING **: Error retrieving accessibility bus address: org.freedesktop.DBus.Error.ServiceUnknown: The name org.a11y.Bus was not provided by any .service files Traceback (most recent call last): File "", line 2158, in _find_spec AttributeError: 'DynamicImporter' object has no attribute 'find_spec' During handling of the above exc...
ادامه مطلبVote count: 0 See the code mult = [lambda x, i=i:x*i for i in range(4)] for v in mult: print(v) But my retu value is: can i get a real value? asked 42 secs agoGuilherme Almeida Let's block ads!...
ادامه مطلبVote count: 0 I am trying to write some code to scrap the website of a UK housebuilder to record a list of houses for sale. I am starting on the page http://www.persimmonhomes.com/sitemap and I have written one part of the code to list all the urls of the housebuilder developments and then the second part of the code to scrap from each of the urls to record prices etc. I know the second part works and I know that the first part lists out all the urls. But for some reason the urls listed by the f...
ادامه مطلب