洞察集合removeAll方法(Insight into Collections removeAll method)
我有一个大小〜200k的列表..我在过滤列表时遇到了一些问题。
这是实施:
public List<> filterList(List<> listToBeFiltered){ List<> removeElementsFromList = listToBeFiltered.parallelStream() .filter(//some filtering logic) .collect(Collectors.toList()); listToBeFiltered.removeAll(removeElementsFromList); return listToBeFiltered; }
我面对代码的问题是,当removeElementsFromList接近listToBeFiltered的大小时,程序将一直停留在removeAll语句中。 非常感谢任何见解/替代解决方案。
I have a list of size ~200k..I am facing some issues while filtering the list.
Here is the implementation:
public List<> filterList(List<> listToBeFiltered){ List<> removeElementsFromList = listToBeFiltered.parallelStream() .filter(//some filtering logic) .collect(Collectors.toList()); listToBeFiltered.removeAll(removeElementsFromList); return listToBeFiltered; }
The problem I face with the code is that the program will remain stuck at the removeAll statement when the removeElementsFromList approaches the size of listToBeFiltered. Any insight/alternate solution is much appreciated.
原文:
最满意答案
保存时转换为int,并在设置值时转换回字符串,
protected void btnUpdate_Click(object sender, EventArgs e) { targetPerson = GetPersonById(Convert.ToInt32(hfId.Value)); targetPerson.Name = txtFName.Text; targetPerson.Age = Convert.ToInt32(txtAge.Text); context.SaveChanges(); }
和
private void DisplayPersonData(Author p) { txtFName.Text = p.Name; txtAge.Text = p.Age.ToString(); }
Just convert to int when you save and convert back to string when you set the value,
protected void btnUpdate_Click(object sender, EventArgs e) { targetPerson = GetPersonById(Convert.ToInt32(hfId.Value)); targetPerson.Name = txtFName.Text; targetPerson.Age = Convert.ToInt32(txtAge.Text); context.SaveChanges(); }
and
private void DisplayPersonData(Author p) { txtFName.Text = p.Name; txtAge.Text = p.Age.ToString(); }
相关问答
更多-
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
ComboBox与TextField(ComboBox with TextField)[2023-07-25]
ComboBox有一个setCellFactory方法,允许您创建自己的自定义ComboBox。 看一下这个例子: Custom Cell Factory 。 ComboBox has a setCellFactory method that allows you to create your own custom ComboBox. Take a look at this example: Custom Cell Factory. -
来自textfield的Java int(Java int from textfield)[2021-12-20]
我在互联网上看到人们使用了事件,但我不确定在这种情况下是否必须使用它。 TextField默认包含空字符串。 如果您不使用某种事件或听众对text属性,则不会获得用户可能输入该字段的值。 在这种情况下,我建议使用TextFormatter来简化事情: TextField tf1 = new TextField(); TextField tf2 = new TextField(); StringConverterconverter = new IntegerStringConverter ... -
您需要做的就是将值重新映射回字符串并加入它们: var stringOfCodes = "".join( code.map { "\($0)" } ) 这为您提供了代码值中的单个字符串。 我觉得有一种更优雅的方式来实现这一目标,但这就是我想到的。 All you need to do is remap the values back to strings and join them: var stringOfCodes = "".join( code.map { "\($0)" } ) This giv ...
-
我尝试使用 - style = text-transform:大写 - 但没有运气。 你应该使用fieldStyle来代替。 这里是演示 。 干杯! I tried using - style=text-transform:uppercase - but no luck. You should have used fieldStyle instead. Here is demo. Cheers!
-
表格显示中更新的NSTableCellView.textField不更新。(Updated NSTableCellView.textField NOT updated in table display.)[2022-06-09]
你犯了一些错误。 首先,你从tableView:objectValueForTableColumn:row返回错误的值。 此方法不请求视图实例,而是请求您的视图实例将要表示的对象。 换句话说,它想知道视图将显示哪个模型对象。 在每种情况下,您的模型对象都非常简单 - 它是tokenText数组中的一个字符串。 func tableView(tableView: NSTableView, objectValueForTableColumn tableColumn: NSTableColumn?, ... -
是的,它会,因为你的所有25个bean都会在你的细节带中迭代,当你到达页脚时它只会有最后一个(这里是第25个)bean的数据,所以它将打印你最后一个bean的数据。 您应该在表格页眉和表格页脚之间添加更多的乐队(组)(细节乐队上方的组标题和详细乐队下方的组页脚),以便在其组页眉和组页脚区域中打印您的bean数据。 Table Header some code Group Header <------------------Print your Header value here(Group acc ...
-
以下用作参考代码.. //Get all your student object from database NSArray* myArray = [self getStudents ]; //Use mutable string to append all the data in single string. NSMutableString* stringName = [NSMutableString stringWithString:@""]; //Traverse through the Stude ...
-
这个小程序使用整数值,它应该使用float或double。 解决这个问题。 更改: int weight, minRun, minBsktBall, hourSleep; 至: double weight, minRun, minBsktBall, hourSleep; &actionPerformed应该更符合以下几点: weight = Double.parseDouble(txtWeight.getText()); minRun = Double.parseDouble(txtRun.getTex ...
-
保存时转换为int,并在设置值时转换回字符串, protected void btnUpdate_Click(object sender, EventArgs e) { targetPerson = GetPersonById(Convert.ToInt32(hfId.Value)); targetPerson.Name = txtFName.Text; targetPerson.Age = Convert.ToInt32(txtAge.Text) ...