在对算法进行一些研究之后,我发现了两个令我困惑的术语.我已经阅读了至少20篇论文,然而,两者都没有明确的定义.我希望有人可以帮助我区分启发式算法和元启发式算法.如果可能,添加它的来源.
ps:我已经知道这些词的含义是什么,但我不知道它们在计算机科学中究竟有什么区别.
提前致谢
我有一个哈希地图,我想复制其他用途.但每当我复制并重复使用它时,它也会改变原来的.这是为什么?
do {
Map<Integer, Map<String, Object>> map1 = originalMap;
//at the second iteration originalMap is the same as map1 of the last iteration,
//eventhough the change was nog accepted;
//do something with map1 (change value);
if(change is accepted) {
originalMap = map1;
}
} while(iteration < 10);
Run Code Online (Sandbox Code Playgroud)
提前致谢
public static <Integer,String, Schedule>Map<Integer, Map<String, Schedule>> deepCopy(Map<Integer, Map<String, Schedule>> original) {
Map<Integer, Map<String, Schedule>> copy = new HashMap<Integer, Map<String, Schedule>>();
for (Map.Entry<Integer, Map<String, Schedule>> entry : original.entrySet()) {
copy.put(entry.getKey(), deepCopy2(entry.getValue()));
}
return …
Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个包含2个自定义视图(B)的UIView(A)
视图B使用Autolayout约束进行设置,并在Interface Builder中进行,包括约束.在viewController的Nib中添加了A.
B - UIImageView(前导= 10,尾随= 10,AlignVertically) - UITextField(前导= 10,尾随= 10,AlignVertically)
ViewController A(300x300,AlignHorizontally,AlignVertically)
在ViewController中,我将A固定为300x300,B1和B2的前导,尾随,顶部和底部固定为0.(这应该使B1和B2为300x150,如果我错过了什么,请原谅我)
加载View BI时,使用以下代码加载其Nib:
override func awakeAfterUsingCoder(aDecoder: NSCoder!) -> AnyObject! {
if self.subviews.count == 0 {
let bundle = NSBundle(forClass: self.dynamicType)
var view = bundle.loadNibNamed("B", owner: nil, options: nil)[0] as B
view.setTranslatesAutoresizingMaskIntoConstraints(false)
let constraints = self.constraints()
self.removeConstraints(constraints)
view.addConstraints(constraints)
return view
}
return self
}
Run Code Online (Sandbox Code Playgroud)
但是当我尝试运行时,我收到以下警告,包括崩溃:
The view hierarchy is not prepared for the constraint: <NSLayoutConstraint:0x7f897ad1acc0 V:[TestProject.B:0x7f897af73840(300)]>
When added to a view, the constraint's items must be descendants …
Run Code Online (Sandbox Code Playgroud)