mirror of
https://github.com/vlang/v.git
synced 2025-09-14 06:52:36 +03:00
fmt: fix alignment of struct init fields (#22025)
This commit is contained in:
parent
99da5726db
commit
c51d30bf53
671 changed files with 18817 additions and 18787 deletions
|
@ -39,10 +39,10 @@ fn (b &BloomFilter[T]) free() {
|
|||
// new_bloom_filter_fast creates a new bloom_filter. `table_size` is 16384, and `num_functions` is 4.
|
||||
pub fn new_bloom_filter_fast[T](hash_func fn (T) u32) &BloomFilter[T] {
|
||||
return &BloomFilter[T]{
|
||||
hash_func: hash_func
|
||||
table_size: 16384
|
||||
hash_func: hash_func
|
||||
table_size: 16384
|
||||
num_functions: 4
|
||||
table: []u8{len: (16384 + 7) / 8}
|
||||
table: []u8{len: (16384 + 7) / 8}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,10 +56,10 @@ pub fn new_bloom_filter[T](hash_func fn (T) u32, table_size int, num_functions i
|
|||
}
|
||||
|
||||
return &BloomFilter[T]{
|
||||
hash_func: hash_func
|
||||
table_size: table_size
|
||||
hash_func: hash_func
|
||||
table_size: table_size
|
||||
num_functions: num_functions
|
||||
table: []u8{len: (table_size + 7) / 8}
|
||||
table: []u8{len: (table_size + 7) / 8}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,10 +99,10 @@ pub fn (l &BloomFilter[T]) @union(r &BloomFilter[T]) !&BloomFilter[T] {
|
|||
}
|
||||
|
||||
mut new_f := BloomFilter[T]{
|
||||
hash_func: l.hash_func
|
||||
table_size: l.table_size
|
||||
hash_func: l.hash_func
|
||||
table_size: l.table_size
|
||||
num_functions: l.num_functions
|
||||
table: []u8{len: (l.table_size + 7) / 8}
|
||||
table: []u8{len: (l.table_size + 7) / 8}
|
||||
}
|
||||
for i in 0 .. l.table.len {
|
||||
new_f.table[i] = l.table[i] | r.table[i]
|
||||
|
@ -119,10 +119,10 @@ pub fn (l &BloomFilter[T]) intersection(r &BloomFilter[T]) !&BloomFilter[T] {
|
|||
}
|
||||
|
||||
mut new_f := BloomFilter[T]{
|
||||
hash_func: l.hash_func
|
||||
table_size: l.table_size
|
||||
hash_func: l.hash_func
|
||||
table_size: l.table_size
|
||||
num_functions: l.num_functions
|
||||
table: []u8{len: (l.table_size + 7) / 8}
|
||||
table: []u8{len: (l.table_size + 7) / 8}
|
||||
}
|
||||
for i in 0 .. l.table.len {
|
||||
new_f.table[i] = l.table[i] & r.table[i]
|
||||
|
|
|
@ -22,10 +22,10 @@ mut:
|
|||
fn new_root_node[T](value T) &BSTreeNode[T] {
|
||||
return &BSTreeNode[T]{
|
||||
is_init: true
|
||||
value: value
|
||||
parent: new_none_node[T](true)
|
||||
left: new_none_node[T](false)
|
||||
right: new_none_node[T](false)
|
||||
value: value
|
||||
parent: new_none_node[T](true)
|
||||
left: new_none_node[T](false)
|
||||
right: new_none_node[T](false)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,8 +33,8 @@ fn new_root_node[T](value T) &BSTreeNode[T] {
|
|||
fn new_node[T](parent &BSTreeNode[T], value T) &BSTreeNode[T] {
|
||||
return &BSTreeNode[T]{
|
||||
is_init: true
|
||||
value: value
|
||||
parent: parent
|
||||
value: value
|
||||
parent: parent
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -50,8 +50,8 @@ pub fn (mut s StateMachine) get_state() string {
|
|||
pub fn (mut s StateMachine) add_state(name string, entry EventHandlerFn, run EventHandlerFn, exit EventHandlerFn) {
|
||||
s.states[name] = State{
|
||||
entry_handler: entry
|
||||
run_handler: run
|
||||
exit_handler: exit
|
||||
run_handler: run
|
||||
exit_handler: exit
|
||||
}
|
||||
if s.states.len == 1 {
|
||||
s.current_state = name
|
||||
|
@ -60,7 +60,7 @@ pub fn (mut s StateMachine) add_state(name string, entry EventHandlerFn, run Eve
|
|||
|
||||
pub fn (mut s StateMachine) add_transition(from string, to string, condition_handler ConditionFn) {
|
||||
t := Transition{
|
||||
to: to
|
||||
to: to
|
||||
condition_handler: condition_handler
|
||||
}
|
||||
if from in s.transitions {
|
||||
|
|
|
@ -22,16 +22,16 @@ pub mut:
|
|||
pub fn (mut q Quadtree) create(x f64, y f64, width f64, height f64, capacity int, depth int, level int) Quadtree {
|
||||
return Quadtree{
|
||||
perimeter: AABB{
|
||||
x: x
|
||||
y: y
|
||||
width: width
|
||||
x: x
|
||||
y: y
|
||||
width: width
|
||||
height: height
|
||||
}
|
||||
capacity: capacity
|
||||
depth: depth
|
||||
level: level
|
||||
capacity: capacity
|
||||
depth: depth
|
||||
level: level
|
||||
particles: []AABB{}
|
||||
nodes: []Quadtree{len: 0, cap: 4}
|
||||
nodes: []Quadtree{len: 0, cap: 4}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,61 +114,61 @@ fn (mut q Quadtree) split() {
|
|||
//(0)
|
||||
q.nodes << Quadtree{
|
||||
perimeter: AABB{
|
||||
x: x + child_width
|
||||
y: y
|
||||
width: child_width
|
||||
x: x + child_width
|
||||
y: y
|
||||
width: child_width
|
||||
height: child_height
|
||||
}
|
||||
capacity: q.capacity
|
||||
depth: q.depth
|
||||
level: next_level
|
||||
capacity: q.capacity
|
||||
depth: q.depth
|
||||
level: next_level
|
||||
particles: []AABB{}
|
||||
nodes: []Quadtree{len: 0, cap: 4}
|
||||
nodes: []Quadtree{len: 0, cap: 4}
|
||||
}
|
||||
|
||||
//(1)
|
||||
q.nodes << Quadtree{
|
||||
perimeter: AABB{
|
||||
x: x
|
||||
y: y
|
||||
width: child_width
|
||||
x: x
|
||||
y: y
|
||||
width: child_width
|
||||
height: child_height
|
||||
}
|
||||
capacity: q.capacity
|
||||
depth: q.depth
|
||||
level: next_level
|
||||
capacity: q.capacity
|
||||
depth: q.depth
|
||||
level: next_level
|
||||
particles: []AABB{}
|
||||
nodes: []Quadtree{len: 0, cap: 4}
|
||||
nodes: []Quadtree{len: 0, cap: 4}
|
||||
}
|
||||
|
||||
//(2)
|
||||
q.nodes << Quadtree{
|
||||
perimeter: AABB{
|
||||
x: x
|
||||
y: y + child_height
|
||||
width: child_width
|
||||
x: x
|
||||
y: y + child_height
|
||||
width: child_width
|
||||
height: child_height
|
||||
}
|
||||
capacity: q.capacity
|
||||
depth: q.depth
|
||||
level: next_level
|
||||
capacity: q.capacity
|
||||
depth: q.depth
|
||||
level: next_level
|
||||
particles: []AABB{}
|
||||
nodes: []Quadtree{len: 0, cap: 4}
|
||||
nodes: []Quadtree{len: 0, cap: 4}
|
||||
}
|
||||
|
||||
//(3)
|
||||
q.nodes << Quadtree{
|
||||
perimeter: AABB{
|
||||
x: x + child_width
|
||||
y: y + child_height
|
||||
width: child_width
|
||||
x: x + child_width
|
||||
y: y + child_height
|
||||
width: child_width
|
||||
height: child_height
|
||||
}
|
||||
capacity: q.capacity
|
||||
depth: q.depth
|
||||
level: next_level
|
||||
capacity: q.capacity
|
||||
depth: q.depth
|
||||
level: next_level
|
||||
particles: []AABB{}
|
||||
nodes: []Quadtree{len: 0, cap: 4}
|
||||
nodes: []Quadtree{len: 0, cap: 4}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,9 +11,9 @@ fn test_insert() {
|
|||
mut qt := Quadtree{}
|
||||
mut test := qt.create(0, 0, 1340, 640, 8, 4, 0)
|
||||
mut pt := AABB{
|
||||
x: 100
|
||||
y: 50
|
||||
width: 60
|
||||
x: 100
|
||||
y: 50
|
||||
width: 60
|
||||
height: 100
|
||||
}
|
||||
assert test.particles == []
|
||||
|
@ -25,9 +25,9 @@ fn test_retrieve() {
|
|||
mut qt := Quadtree{}
|
||||
mut test := qt.create(0, 0, 1340, 640, 8, 4, 0)
|
||||
mut pt := AABB{
|
||||
x: 100
|
||||
y: 50
|
||||
width: 60
|
||||
x: 100
|
||||
y: 50
|
||||
width: 60
|
||||
height: 100
|
||||
}
|
||||
test.insert(pt)
|
||||
|
@ -40,9 +40,9 @@ fn test_clear() {
|
|||
mut test := qt.create(0, 0, 1340, 640, 8, 4, 0)
|
||||
mut test_clone := qt.create(0, 0, 1340, 640, 8, 4, 0)
|
||||
mut pt := AABB{
|
||||
x: 100
|
||||
y: 50
|
||||
width: 60
|
||||
x: 100
|
||||
y: 50
|
||||
width: 60
|
||||
height: 100
|
||||
}
|
||||
test.split()
|
||||
|
@ -72,9 +72,9 @@ fn test_get_index() {
|
|||
mut qt := Quadtree{}
|
||||
mut test := qt.create(0, 0, 1340, 640, 8, 4, 0)
|
||||
mut pt := AABB{
|
||||
x: 100
|
||||
y: 50
|
||||
width: 60
|
||||
x: 100
|
||||
y: 50
|
||||
width: 60
|
||||
height: 100
|
||||
}
|
||||
test.particles << pt
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue