我想使用unix命令打印文本文件每行中的字符数.我知道powershell很简单
gc abc.txt | % {$_.length}
Run Code Online (Sandbox Code Playgroud)
但我需要unix命令.
在我的申请中,我们已经有了
Map<String, List<String>>
Run Code Online (Sandbox Code Playgroud)
现在我们得到了另一个用例,需要找到一个映射到列表中特定字符串的键.
我正在考虑写下面的内容:
string getKey(Map<String, List<String>> m, String str) {
for (Entry<String, List<String>> entry :m.entrySet()) {
if(entry.getValue().contains(str)) {
retrun entry.getKey();
}
}
return null;
}
Run Code Online (Sandbox Code Playgroud)
Map可以有最多2000个条目.每个List人最多可以有500 String秒.
任何可能更合适的建议?Map如果有更好的方法,我也可以更改初始数据结构().