我有一个带有2个参数的CardViews的recyclerView(两个都是字符串),其中一个是标题,我想有一个按钮按照字母顺序对它们进行排序.
因为它没有太多元素我决定使用插入排序o(n ^ 2),这是我的实现:
public void ISortDes(String[]strings){
int j;
String key;
int i;
for (j = 1; j < strings.length; j++)
{
key = strings[ j ];
for(i = j - 1; (i >= 0) ; i--)
{
if (key.compareTo(strings[i]) > 0){
break;
}
strings[ i+1 ] = strings[ i ];
}
strings[ i+1 ] = key;
}
for (int k = 0; k < strings.length; k++){
System.out.println(strings[k]);
}
}
Run Code Online (Sandbox Code Playgroud)
它需要一系列字符串并命令它们.
这是我的RecyclerView采用参数的方法:
private void initializeData() {
categories = new ArrayList<>(); …Run Code Online (Sandbox Code Playgroud) 我正在尝试通过以下方式创建输入:
\n\n Tx = 318\n n_freq = 101\n input_anchor = Input(shape=(n_freq,Tx), name=\'input_anchor\')\nRun Code Online (Sandbox Code Playgroud)\n\n当我跑步时:
\n\n input_anchor.shape\nRun Code Online (Sandbox Code Playgroud)\n\n我得到:
\n\n TensorShape([None, 101, 318])\nRun Code Online (Sandbox Code Playgroud)\n\n后来,当我尝试在模型中使用该输入时,出现以下错误:
\n\n TypeError: Cannot iterate over a tensor with unknown first dimension.\nRun Code Online (Sandbox Code Playgroud)\n\n在张量流的 opy.py中,我发现这个代码块很可能是我的代码失败的地方:
\n\n def __iter__(self):\n if not context.executing_eagerly():\n raise TypeError(\n "Tensor objects are only iterable when eager execution is "\n "enabled. To iterate over this tensor use tf.map_fn.")\n shape = self._shape_tuple()\n if shape is None:\n raise TypeError("Cannot iterate over a tensor with …Run Code Online (Sandbox Code Playgroud) python machine-learning deep-learning tensorflow tensorflow2.0
我有以下形式的一系列哈希:
{"user_id"=>2, "user_name"=>"Pepo", "beneficiary_document"=>"43991028", "calification_by_qualifier"=>5.0}
{"user_id"=>2, "user_name"=>"Pepo", "beneficiary_document"=>"71730550", "calification_by_qualifier"=>3.8499999999999996}
{"user_id"=>3, "user_name"=>"Carlos", "beneficiary_document"=>"43991028", "calification_by_qualifier"=>0.0}
{"user_id"=>3, "user_name"=>"Carlos", "beneficiary_document"=>"71730550", "calification_by_qualifier"=>3.4}
Run Code Online (Sandbox Code Playgroud)
基本上我想将该数组分成包含相同键值的数组beneficiary_document,所以对于这个例子,我希望有两个数组,一个包含:
{"user_id"=>2, "user_name"=>"Pepo", "beneficiary_document"=>"43991028", "calification_by_qualifier"=>5.0}
{"user_id"=>3, "user_name"=>"Carlos", "beneficiary_document"=>"43991028", "calification_by_qualifier"=>0.0}
Run Code Online (Sandbox Code Playgroud)
另一个包含
{"user_id"=>3, "user_name"=>"Carlos", "beneficiary_document"=>"71730550", "calification_by_qualifier"=>3.4}
{"user_id"=>2, "user_name"=>"Pepo", "beneficiary_document"=>"71730550", "calification_by_qualifier"=>3.8499999999999996}
Run Code Online (Sandbox Code Playgroud)
我怎么能批出这个?
非常感谢阅读.
下面的代码是一个完美的c ++代码,老师要求我们重写它,以便只在一条指令中输入和输出.
我真的不知道怎么做,而且我已经做了几个小时的研究.
我真的很感激如何做到这一点.
#include <iostream>
using namespace std;
int main()
{
int c;
cin >> c;
std;
if(c == 0) {
cout << "user sent 0" << endl;
}
else {
cout << "user sent a number different from 0" << endl;
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
谢谢阅读.
基本上我想要做的是删除一个文件和一个记录(其中包含文件路径)当记录是三个月大,该文件是通过Carrierwave上传的.
这有点我删除记录和文件的想法.
# Code for deleteing PDF files (receipts) every 90 days
def auto_delete_receipts
#get user id from params or as a method parameter
user = params[:id]
user.receipts.each do |receipt|
#check if receipt is three months old
receipt.remove_receiptFile!
receipt.save
#end
end
end
Run Code Online (Sandbox Code Playgroud)
所以我想知道我应该在哪里找到我的方法以及如何在每次记录三个月之后自动运行它,以便删除它.
谢谢阅读.