-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from bavix/bxp-docs
godoc
- Loading branch information
Showing
11 changed files
with
712 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,4 +31,5 @@ issues: | |
exclude-rules: | ||
- path: (.+)_test.go | ||
linters: | ||
- gochecknoglobals | ||
- dupl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,37 @@ | ||
package boxpacker3 | ||
|
||
// RotationType represents the type of rotation for an item. | ||
type RotationType int | ||
|
||
// RotationTypeWhd represents the rotation type where the width is the longest dimension. | ||
const ( | ||
RotationTypeWhd RotationType = iota | ||
// RotationTypeHwd represents the rotation type where the height is the longest dimension. | ||
RotationTypeHwd | ||
// RotationTypeHdw represents the rotation type where the depth is the longest dimension. | ||
RotationTypeHdw | ||
// RotationTypeDhw represents the rotation type where the depth is the longest dimension. | ||
RotationTypeDhw | ||
// RotationTypeDwh represents the rotation type where the width is the longest dimension. | ||
RotationTypeDwh | ||
// RotationTypeWdh represents the rotation type where the height is the longest dimension. | ||
RotationTypeWdh | ||
) | ||
|
||
// Axis represents the axis of a dimension. | ||
type Axis int | ||
|
||
// WidthAxis represents the width axis. | ||
const ( | ||
WidthAxis Axis = iota | ||
// HeightAxis represents the height axis. | ||
HeightAxis | ||
// DepthAxis represents the depth axis. | ||
DepthAxis | ||
) | ||
|
||
type ( | ||
Pivot [3]float64 | ||
Dimension [3]float64 | ||
) | ||
// Pivot represents the position of an item within a box. | ||
type Pivot [3]float64 | ||
|
||
// Dimension represents the dimensions of an item or a box. | ||
type Dimension [3]float64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,35 @@ | ||
package boxpacker3 | ||
|
||
// CopyPtr creates a copy of a pointer. | ||
// | ||
// It takes a pointer to a generic type T as an argument and returns a new pointer | ||
// to a copy of the original value. If the original pointer is nil, it returns nil. | ||
func CopyPtr[T any](original *T) *T { | ||
// If the original pointer is nil, return nil. | ||
if original == nil { | ||
return nil | ||
} | ||
|
||
// Create a copy of the value pointed to by the original pointer. | ||
copyOfValue := *original | ||
|
||
// Return a new pointer to the copied value. | ||
return ©OfValue | ||
} | ||
|
||
// CopySlicePtr creates a copy of a slice of pointers. | ||
// | ||
// It takes a slice of pointers as an argument and returns a new slice with the same | ||
// elements, but with each element being a copy of the original. | ||
func CopySlicePtr[T any](data []*T) []*T { | ||
// Create a new slice with the same length as the original. | ||
result := make([]*T, len(data)) | ||
|
||
// Iterate over the original slice and copy each element to the new slice. | ||
for i, item := range data { | ||
result[i] = CopyPtr(item) | ||
} | ||
|
||
// Return the new slice. | ||
return result | ||
} |
Oops, something went wrong.