我有以下搜索条件的地图:
private final Map<String, Predicate> searchMap = new HashMap<>();
private void initSearchMap() {
Predicate<Person> allDrivers = p -> p.getAge() >= 16;
Predicate<Person> allDraftees = p -> p.getAge() >= 18
&& p.getAge() <= 25
&& p.getGender() == Gender.MALE;
Predicate<Person> allPilots = p -> p.getAge() >= 23
&& p.getAge() <=65;
searchMap.put("allDrivers", allDrivers);
searchMap.put("allDraftees", allDraftees);
searchMap.put("allPilots", allPilots);
}
Run Code Online (Sandbox Code Playgroud)
我通过以下方式使用此地图:
pl.stream()
.filter(search.getCriteria("allPilots"))
.forEach(p -> {
p.printl(p.getPrintStyle("westernNameAgePhone"));
});
Run Code Online (Sandbox Code Playgroud)
我想知道,如何将一些参数传递到谓词的映射中?
即我想通过字符串缩写从地图中获取谓词,并将参数插入从地图谓词中取出的参数.
pl.stream()
.filter(search.getCriteria("allPilots",45, 56))
.forEach(p -> {
p.printl(p.getPrintStyle("westernNameAgePhone"));
});
Run Code Online (Sandbox Code Playgroud)
这里是链接从我用Google搜索这个地图谓语方法.
我有两个矩阵:A和B.
谢谢你回答我的问题!
帮助文件
#import <Foundation/Foundation.h>
#include <Accelerate/Accelerate.h>
@interface Working_with_matrices : NSObject
-(int)invert_matrix:(int) N andWithMatrix:(double*) matrix;
@end
Run Code Online (Sandbox Code Playgroud)
实施文件
#import "Working_with_matrices.h"
#include <Accelerate/Accelerate.h>
@implementation Working_with_matrices
-(int) matrix_invert:(int) N andWithMatrix:(double*)matrix
{
int error=0;
int *pivot = malloc(N*N*sizeof(int));
double *workspace = malloc(N*sizeof(double));
dgetrf_(&N, &N, matrix, &N, pivot, &error);
if (error != 0) {
NSLog(@"Error 1");
return error;
}
dgetri_(&N, matrix, &N, pivot, workspace, &N, &error);
if (error != 0) {
NSLog(@"Error 2");
return error;
}
free(pivot);
free(workspace);
return error;
} …Run Code Online (Sandbox Code Playgroud) 一些先决条件:
我没有使用 Oracle DB 序列生成器。取而代之的是,我依赖于 Hibernate 序列生成器 ex
@Entity
@Table(name = "JPA_ENTITY_A")
@GenericGenerator(name = "system-uuid", strategy = "uuid2")
public class JpaEntityA{
@Id
@Type(type = "uuid-binary")
@GeneratedValue(generator = "system-uuid")
private UUID id;
@Column(name="NAME_WITH_ID")
String nameWithGeneratedId;
}
Run Code Online (Sandbox Code Playgroud)
我想要的是将以下生成的值保留到“NAME_WITH_ID”列中: this.nameWithGeneratedId+this.id
是否可行执行以下操作:
public String getNameWithGeneratedId(){
return this.nameWithGeneratedId+this.id;//hope that the returned value will be persisted
}
Run Code Online (Sandbox Code Playgroud)
或者是否可以在将实体持久化到 DB 生成的 id 之前提前检索?如果是,那么我该如何实现呢?(根据下面的评论,这是不可能的)
提前谢谢。
我有一串RNA,即:
AUGGCCAUA
Run Code Online (Sandbox Code Playgroud)
我想通过以下方式生成所有子字符串:
#starting from 0 character
AUG, GCC, AUA
#starting from 1 character
UGG, CCA
#starting from 2 character
GGC, CAU
Run Code Online (Sandbox Code Playgroud)
我编写了一个解决第一个子问题的代码:
for i in range(0,len(rna)):
if fmod(i,3)==0:
print rna[i:i+3]
Run Code Online (Sandbox Code Playgroud)
我试图改变起始位置,即:
for i in range(1,len(rna)):
Run Code Online (Sandbox Code Playgroud)
但它产生了不正确的结果:
GCC, UA #instead of UGG, CCA
Run Code Online (Sandbox Code Playgroud)
你能不能给我一个提示我的错误在哪里?
我正在尝试使用以下宏读取文本文件(这些文件由外部程序生成,无法编写).
While Not EOF(int_current_file)
Line Input #int_current_file, buf
If Left(buf, 1) <> "#" Then
buf1 = Split(buf, "=")
Print #int_master_file, CInt(Left(buf, 2)) & ";" & CInt(Mid(buf, 3, 4)) & ";" & CInt(Mid(buf, 7, 3)) & ";" & CInt(Mid(buf, 10, 1)) & ";" & CDbl(buf1(1) / 100000000) & ";" & CDate(file_date) & ";" & Mid(file_name, 4, 3)
End If
'Line Input #int_current_file, buf
'Debug.Print Data
Wend
Run Code Online (Sandbox Code Playgroud)
但是,在此文件的第二行,我有以下字符串:
=01082013=01072013=31072013=06082013=1640=380441=21=000001249=#02IFS86.G84=IFSSS5=7?K!?i—?42??4?{¤?o$]?•?p ?1‹;±~†?RL??‰®?? ????^±>_‰
当宏尝试读取此行时,error 62会发生Input past end of file.
我该如何解决这个问题?
这是网站,我想解析:俄罗斯网站
以下是提取我需要的信息的代码:
# -*- coding: utf-8 -*-
from scrapy.spider import Spider
from scrapy.selector import Selector
from flats.items import FlatsItem
class DmozSpider(Spider):
name = "dmoz"
start_urls = ['http://rieltor.ua/flats-sale/?ncrnd=6510']
def parse(self, response):
sel=Selector(response)
flats=sel.xpath('//*[@id="content"]')
flats_stored_info=[]
flat_item=FlatsItem()
for flat in flats:
flat_item['square']=[s.encode("utf-8") for s in sel.xpath('//div/strong[@class="param"][1]/text()').extract()]
flat_item['rooms_floor_floors']=[s.encode("utf-8") for s in sel.xpath('//div/strong[@class="param"][2]/text()').extract()]
flat_item['address']=[s.encode("utf-8") for s in flat.xpath('//*[@id="content"]//h2/a/text()').extract()]
flat_item['price']=[s.encode("utf-8") for s in flat.xpath('//div[@class="cost"]/strong/text()').extract()]
flat_item['subway']=[s.encode("utf-8") for s in flat.xpath('//span[@class="flag flag-location"]/a/text()').extract()]
flats_stored_info.append(flat_item)
return flats_stored_info
Run Code Online (Sandbox Code Playgroud)
我如何转储到json文件
scrapy crawl dmoz -o items.json -t json
Run Code Online (Sandbox Code Playgroud)
问题是当我替换上面的代码在控制台中打印提取的信息时,如下所示:
flat_item['square']=sel.xpath('//div/strong[@class="param"][1]/text()').extract()
for bla …Run Code Online (Sandbox Code Playgroud)