2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
13
Task/Arena-storage-pool/Fortran/arena-storage-pool.f
Normal file
13
Task/Arena-storage-pool/Fortran/arena-storage-pool.f
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
SUBROUTINE CHECK(A,N) !Inspect matrix A.
|
||||
REAL A(:,:) !The matrix, whatever size it is.
|
||||
INTEGER N !The order.
|
||||
REAL B(N,N) !A scratchpad, size known on entry..
|
||||
INTEGER, ALLOCATABLE::TROUBLE(:) !But for this, I'll decide later.
|
||||
INTEGER M
|
||||
|
||||
M = COUNT(A(1:N,1:N).LE.0) !Some maximum number of troublemakers.
|
||||
|
||||
ALLOCATE (TROUBLE(1:M**3)) !Just enough.
|
||||
|
||||
DEALLOCATE(TROUBLE) !Not necessary.
|
||||
END SUBROUTINE CHECK !As TROUBLE is declared within CHECK.
|
||||
27
Task/Arena-storage-pool/Rust/arena-storage-pool.rust
Normal file
27
Task/Arena-storage-pool/Rust/arena-storage-pool.rust
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#![feature(rustc_private)]
|
||||
|
||||
extern crate arena;
|
||||
|
||||
use arena::TypedArena;
|
||||
|
||||
fn main() {
|
||||
// Memory is allocated using the default allocator (currently jemalloc). The memory is
|
||||
// allocated in chunks, and when one chunk is full another is allocated. This ensures that
|
||||
// references to an arena don't become invalid when the original chunk runs out of space. The
|
||||
// chunk size is configurable as an argument to TypedArena::with_capacity if necessary.
|
||||
let arena = TypedArena::new();
|
||||
|
||||
// The arena crate contains two types of arenas: TypedArena and Arena. Arena is
|
||||
// reflection-basd and slower, but can allocate objects of any type. TypedArena is faster, and
|
||||
// can allocate only objects of one type. The type is determined by type inference--if you try
|
||||
// to allocate an integer, then Rust's compiler knows it is an integer arena.
|
||||
let v1 = arena.alloc(1i32);
|
||||
|
||||
// TypedArena returns a mutable reference
|
||||
let v2 = arena.alloc(3);
|
||||
*v2 += 38;
|
||||
println!("{}", *v1 + *v2);
|
||||
|
||||
// The arena's destructor is called as it goes out of scope, at which point it deallocates
|
||||
// everything stored within it at once.
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue