Skip to content

Instantly share code, notes, and snippets.

// Goal of this file:
// Figure out how the lifetimes of a mutable reference is exactly defined
// and what happens if a `&mut` reference A is assigned to another `&mut`
// reference B - is the lifetime of B inheriated from A or does the lifetime
// of B depends on the location of the definition of B?
struct Entry<'a> {
id: isize,
next: Option<&'a mut Entry<'a>>,
}
@jviereck
jviereck / .rs
Created February 20, 2015 16:02
fn GetOffsetParent(self) -> Option<Temporary<Element>> {
let window = window_from_node(self).root().r();
let page = window.page();
let self_node: JSRef<Node> = NodeCast::from_ref(self);
match page.offset_parent_query(self_node.to_trusted_node_address()) {
Some(ref node_address) => {
let temp_node = from_untrusted_node_address(
window.get_cx().get_rt(), node_address);
fn GetOffsetParent(self) -> Option<Temporary<Element>> {
let page = window_from_node(self).root().r().page();
let self_node: JSRef<Node> = NodeCast::from_ref(self);
match page.offset_parent_query(self_node.to_trusted_node_address()) {
Some(ref node_address) => {
let temp_node = from_untrusted_node_address(
page.js_info().as_ref().unwrap().js_context.rt.deref().ptr, node_address);
// COMPILER ERROR:
// servo/components/script/dom/htmlelement.rs:131:68: 131:75 error: type `alloc::rc::Rc<js::rust::rt_rsrc>` does not implement any method in scope named `deref`
#![feature(core)]
#![feature(collections)]
use std::collections::DList;
struct Node<'a> {
id: isize,
next: Option<&'a mut Node<'a>>
}
struct Entry {
id: int
}
fn consume_mutable_entry(entry: &mut Entry) {
println!("Entry.id = {} | from consume_mutable_entry", entry.id);
entry.id = entry.id + 1;
println!("Entry.id = {} | from consume_mutable_entry", entry.id);
}
=== For Term Based Model: ==
AP for topic #51: 0.6643508953168044
AP for topic #52: 0.589976006398294
AP for topic #53: 0.509090909090909
AP for topic #54: 0.30280665133055007
AP for topic #55: 0.7520661157024794
AP for topic #56: 0.4350490551447489
AP for topic #57: 0.46464646464646475
AP for topic #58: 0.2690541781450872
Merge document numbers...
Merge df hash map...
Setup the queries to find documents to...
Processing the documents...
Query all document zip files...
Processing documents...
Stopped time = in 9.764009 sec.
---------------------
TfIdfQuery: Airbus Subsidies
0 1 2 3 4 5 6 8 9 11 13 15 19 25 26 40 53
Merge document numbers...
Merge df hash map...
Setup the queries to find documents to...
Processing the documents...
Query all document zip files...
Processing documents...
Stopped time = in 25.557281 sec.
ScoredResult(AP8803180287,79.69622382069986)
ScoredResult(AP8803160292,75.68674414705036)
ScoredResult(AP8807310085,70.30657540696771)
package ch.ethz.dal.tinyir.alerts
import ch.ethz.dal.tinyir.io.TipsterStream
import ch.ethz.dal.tinyir.util.StopWatch
import ch.ethz.dal.tinyir.lectures.TipsterGroundTruth
import ch.ethz.dal.tinyir.lectures.PrecisionRecall
import java.io.File
import java.io.InputStream
import java.util.zip.ZipFile
import java.util.zip.ZipEntry
0 1 | 1
1 0 | 2
Daraus machen
1 0 | 2
0 1 | 1
Dann die erste Zeile das n-fache auf die anderen Addieren: