github.com/hamba/slices@v0.2.1-0.20220316050741-75c057d92699/ops.gen.go (about) 1 package slices 2 3 // Code generated by 'gen.go'. DO NOT EDIT. 4 5 import "unsafe" 6 7 // Contains 8 func boolContains(sptr, vptr unsafe.Pointer) bool { 9 v := *(*bool)(vptr) 10 for _, vv := range *(*[]bool)(sptr) { 11 if vv == v { 12 return true 13 } 14 } 15 return false 16 } 17 18 func stringContains(sptr, vptr unsafe.Pointer) bool { 19 v := *(*string)(vptr) 20 for _, vv := range *(*[]string)(sptr) { 21 if vv == v { 22 return true 23 } 24 } 25 return false 26 } 27 28 func intContains(sptr, vptr unsafe.Pointer) bool { 29 v := *(*int)(vptr) 30 for _, vv := range *(*[]int)(sptr) { 31 if vv == v { 32 return true 33 } 34 } 35 return false 36 } 37 38 func int8Contains(sptr, vptr unsafe.Pointer) bool { 39 v := *(*int8)(vptr) 40 for _, vv := range *(*[]int8)(sptr) { 41 if vv == v { 42 return true 43 } 44 } 45 return false 46 } 47 48 func int16Contains(sptr, vptr unsafe.Pointer) bool { 49 v := *(*int16)(vptr) 50 for _, vv := range *(*[]int16)(sptr) { 51 if vv == v { 52 return true 53 } 54 } 55 return false 56 } 57 58 func int32Contains(sptr, vptr unsafe.Pointer) bool { 59 v := *(*int32)(vptr) 60 for _, vv := range *(*[]int32)(sptr) { 61 if vv == v { 62 return true 63 } 64 } 65 return false 66 } 67 68 func int64Contains(sptr, vptr unsafe.Pointer) bool { 69 v := *(*int64)(vptr) 70 for _, vv := range *(*[]int64)(sptr) { 71 if vv == v { 72 return true 73 } 74 } 75 return false 76 } 77 78 func uintContains(sptr, vptr unsafe.Pointer) bool { 79 v := *(*uint)(vptr) 80 for _, vv := range *(*[]uint)(sptr) { 81 if vv == v { 82 return true 83 } 84 } 85 return false 86 } 87 88 func uint8Contains(sptr, vptr unsafe.Pointer) bool { 89 v := *(*uint8)(vptr) 90 for _, vv := range *(*[]uint8)(sptr) { 91 if vv == v { 92 return true 93 } 94 } 95 return false 96 } 97 98 func uint16Contains(sptr, vptr unsafe.Pointer) bool { 99 v := *(*uint16)(vptr) 100 for _, vv := range *(*[]uint16)(sptr) { 101 if vv == v { 102 return true 103 } 104 } 105 return false 106 } 107 108 func uint32Contains(sptr, vptr unsafe.Pointer) bool { 109 v := *(*uint32)(vptr) 110 for _, vv := range *(*[]uint32)(sptr) { 111 if vv == v { 112 return true 113 } 114 } 115 return false 116 } 117 118 func uint64Contains(sptr, vptr unsafe.Pointer) bool { 119 v := *(*uint64)(vptr) 120 for _, vv := range *(*[]uint64)(sptr) { 121 if vv == v { 122 return true 123 } 124 } 125 return false 126 } 127 128 func float32Contains(sptr, vptr unsafe.Pointer) bool { 129 v := *(*float32)(vptr) 130 for _, vv := range *(*[]float32)(sptr) { 131 if vv == v { 132 return true 133 } 134 } 135 return false 136 } 137 138 func float64Contains(sptr, vptr unsafe.Pointer) bool { 139 v := *(*float64)(vptr) 140 for _, vv := range *(*[]float64)(sptr) { 141 if vv == v { 142 return true 143 } 144 } 145 return false 146 } 147 148 // LesserOf 149 func stringLesser(ptr unsafe.Pointer) func(i, j int) bool { 150 return func(i, j int) bool { 151 v := *(*[]string)(ptr) 152 return v[i] < v[j] 153 } 154 } 155 156 func intLesser(ptr unsafe.Pointer) func(i, j int) bool { 157 return func(i, j int) bool { 158 v := *(*[]int)(ptr) 159 return v[i] < v[j] 160 } 161 } 162 163 func int8Lesser(ptr unsafe.Pointer) func(i, j int) bool { 164 return func(i, j int) bool { 165 v := *(*[]int8)(ptr) 166 return v[i] < v[j] 167 } 168 } 169 170 func int16Lesser(ptr unsafe.Pointer) func(i, j int) bool { 171 return func(i, j int) bool { 172 v := *(*[]int16)(ptr) 173 return v[i] < v[j] 174 } 175 } 176 177 func int32Lesser(ptr unsafe.Pointer) func(i, j int) bool { 178 return func(i, j int) bool { 179 v := *(*[]int32)(ptr) 180 return v[i] < v[j] 181 } 182 } 183 184 func int64Lesser(ptr unsafe.Pointer) func(i, j int) bool { 185 return func(i, j int) bool { 186 v := *(*[]int64)(ptr) 187 return v[i] < v[j] 188 } 189 } 190 191 func uintLesser(ptr unsafe.Pointer) func(i, j int) bool { 192 return func(i, j int) bool { 193 v := *(*[]uint)(ptr) 194 return v[i] < v[j] 195 } 196 } 197 198 func uint8Lesser(ptr unsafe.Pointer) func(i, j int) bool { 199 return func(i, j int) bool { 200 v := *(*[]uint8)(ptr) 201 return v[i] < v[j] 202 } 203 } 204 205 func uint16Lesser(ptr unsafe.Pointer) func(i, j int) bool { 206 return func(i, j int) bool { 207 v := *(*[]uint16)(ptr) 208 return v[i] < v[j] 209 } 210 } 211 212 func uint32Lesser(ptr unsafe.Pointer) func(i, j int) bool { 213 return func(i, j int) bool { 214 v := *(*[]uint32)(ptr) 215 return v[i] < v[j] 216 } 217 } 218 219 func uint64Lesser(ptr unsafe.Pointer) func(i, j int) bool { 220 return func(i, j int) bool { 221 v := *(*[]uint64)(ptr) 222 return v[i] < v[j] 223 } 224 } 225 226 func float32Lesser(ptr unsafe.Pointer) func(i, j int) bool { 227 return func(i, j int) bool { 228 v := *(*[]float32)(ptr) 229 return v[i] < v[j] 230 } 231 } 232 233 func float64Lesser(ptr unsafe.Pointer) func(i, j int) bool { 234 return func(i, j int) bool { 235 v := *(*[]float64)(ptr) 236 return v[i] < v[j] 237 } 238 } 239 240 // GreaterOf 241 func stringGreater(ptr unsafe.Pointer) func(i, j int) bool { 242 return func(i, j int) bool { 243 v := *(*[]string)(ptr) 244 return v[i] > v[j] 245 } 246 } 247 248 func intGreater(ptr unsafe.Pointer) func(i, j int) bool { 249 return func(i, j int) bool { 250 v := *(*[]int)(ptr) 251 return v[i] > v[j] 252 } 253 } 254 255 func int8Greater(ptr unsafe.Pointer) func(i, j int) bool { 256 return func(i, j int) bool { 257 v := *(*[]int8)(ptr) 258 return v[i] > v[j] 259 } 260 } 261 262 func int16Greater(ptr unsafe.Pointer) func(i, j int) bool { 263 return func(i, j int) bool { 264 v := *(*[]int16)(ptr) 265 return v[i] > v[j] 266 } 267 } 268 269 func int32Greater(ptr unsafe.Pointer) func(i, j int) bool { 270 return func(i, j int) bool { 271 v := *(*[]int32)(ptr) 272 return v[i] > v[j] 273 } 274 } 275 276 func int64Greater(ptr unsafe.Pointer) func(i, j int) bool { 277 return func(i, j int) bool { 278 v := *(*[]int64)(ptr) 279 return v[i] > v[j] 280 } 281 } 282 283 func uintGreater(ptr unsafe.Pointer) func(i, j int) bool { 284 return func(i, j int) bool { 285 v := *(*[]uint)(ptr) 286 return v[i] > v[j] 287 } 288 } 289 290 func uint8Greater(ptr unsafe.Pointer) func(i, j int) bool { 291 return func(i, j int) bool { 292 v := *(*[]uint8)(ptr) 293 return v[i] > v[j] 294 } 295 } 296 297 func uint16Greater(ptr unsafe.Pointer) func(i, j int) bool { 298 return func(i, j int) bool { 299 v := *(*[]uint16)(ptr) 300 return v[i] > v[j] 301 } 302 } 303 304 func uint32Greater(ptr unsafe.Pointer) func(i, j int) bool { 305 return func(i, j int) bool { 306 v := *(*[]uint32)(ptr) 307 return v[i] > v[j] 308 } 309 } 310 311 func uint64Greater(ptr unsafe.Pointer) func(i, j int) bool { 312 return func(i, j int) bool { 313 v := *(*[]uint64)(ptr) 314 return v[i] > v[j] 315 } 316 } 317 318 func float32Greater(ptr unsafe.Pointer) func(i, j int) bool { 319 return func(i, j int) bool { 320 v := *(*[]float32)(ptr) 321 return v[i] > v[j] 322 } 323 } 324 325 func float64Greater(ptr unsafe.Pointer) func(i, j int) bool { 326 return func(i, j int) bool { 327 v := *(*[]float64)(ptr) 328 return v[i] > v[j] 329 } 330 } 331 332 // Intersect 333 func stringIntersect(sptr, optr unsafe.Pointer) interface{} { 334 slice := make([]string, len(*(*[]string)(sptr))) 335 copy(slice, *(*[]string)(sptr)) 336 for i := 0; i < len(slice); i++ { 337 found := false 338 for _, v := range *(*[]string)(optr) { 339 if v == slice[i] { 340 found = true 341 break 342 } 343 } 344 if !found { 345 slice = append(slice[:i], slice[i+1:]...) 346 i-- 347 } 348 } 349 return slice 350 } 351 352 func intIntersect(sptr, optr unsafe.Pointer) interface{} { 353 slice := make([]int, len(*(*[]int)(sptr))) 354 copy(slice, *(*[]int)(sptr)) 355 for i := 0; i < len(slice); i++ { 356 found := false 357 for _, v := range *(*[]int)(optr) { 358 if v == slice[i] { 359 found = true 360 break 361 } 362 } 363 if !found { 364 slice = append(slice[:i], slice[i+1:]...) 365 i-- 366 } 367 } 368 return slice 369 } 370 371 func int8Intersect(sptr, optr unsafe.Pointer) interface{} { 372 slice := make([]int8, len(*(*[]int8)(sptr))) 373 copy(slice, *(*[]int8)(sptr)) 374 for i := 0; i < len(slice); i++ { 375 found := false 376 for _, v := range *(*[]int8)(optr) { 377 if v == slice[i] { 378 found = true 379 break 380 } 381 } 382 if !found { 383 slice = append(slice[:i], slice[i+1:]...) 384 i-- 385 } 386 } 387 return slice 388 } 389 390 func int16Intersect(sptr, optr unsafe.Pointer) interface{} { 391 slice := make([]int16, len(*(*[]int16)(sptr))) 392 copy(slice, *(*[]int16)(sptr)) 393 for i := 0; i < len(slice); i++ { 394 found := false 395 for _, v := range *(*[]int16)(optr) { 396 if v == slice[i] { 397 found = true 398 break 399 } 400 } 401 if !found { 402 slice = append(slice[:i], slice[i+1:]...) 403 i-- 404 } 405 } 406 return slice 407 } 408 409 func int32Intersect(sptr, optr unsafe.Pointer) interface{} { 410 slice := make([]int32, len(*(*[]int32)(sptr))) 411 copy(slice, *(*[]int32)(sptr)) 412 for i := 0; i < len(slice); i++ { 413 found := false 414 for _, v := range *(*[]int32)(optr) { 415 if v == slice[i] { 416 found = true 417 break 418 } 419 } 420 if !found { 421 slice = append(slice[:i], slice[i+1:]...) 422 i-- 423 } 424 } 425 return slice 426 } 427 428 func int64Intersect(sptr, optr unsafe.Pointer) interface{} { 429 slice := make([]int64, len(*(*[]int64)(sptr))) 430 copy(slice, *(*[]int64)(sptr)) 431 for i := 0; i < len(slice); i++ { 432 found := false 433 for _, v := range *(*[]int64)(optr) { 434 if v == slice[i] { 435 found = true 436 break 437 } 438 } 439 if !found { 440 slice = append(slice[:i], slice[i+1:]...) 441 i-- 442 } 443 } 444 return slice 445 } 446 447 func uintIntersect(sptr, optr unsafe.Pointer) interface{} { 448 slice := make([]uint, len(*(*[]uint)(sptr))) 449 copy(slice, *(*[]uint)(sptr)) 450 for i := 0; i < len(slice); i++ { 451 found := false 452 for _, v := range *(*[]uint)(optr) { 453 if v == slice[i] { 454 found = true 455 break 456 } 457 } 458 if !found { 459 slice = append(slice[:i], slice[i+1:]...) 460 i-- 461 } 462 } 463 return slice 464 } 465 466 func uint8Intersect(sptr, optr unsafe.Pointer) interface{} { 467 slice := make([]uint8, len(*(*[]uint8)(sptr))) 468 copy(slice, *(*[]uint8)(sptr)) 469 for i := 0; i < len(slice); i++ { 470 found := false 471 for _, v := range *(*[]uint8)(optr) { 472 if v == slice[i] { 473 found = true 474 break 475 } 476 } 477 if !found { 478 slice = append(slice[:i], slice[i+1:]...) 479 i-- 480 } 481 } 482 return slice 483 } 484 485 func uint16Intersect(sptr, optr unsafe.Pointer) interface{} { 486 slice := make([]uint16, len(*(*[]uint16)(sptr))) 487 copy(slice, *(*[]uint16)(sptr)) 488 for i := 0; i < len(slice); i++ { 489 found := false 490 for _, v := range *(*[]uint16)(optr) { 491 if v == slice[i] { 492 found = true 493 break 494 } 495 } 496 if !found { 497 slice = append(slice[:i], slice[i+1:]...) 498 i-- 499 } 500 } 501 return slice 502 } 503 504 func uint32Intersect(sptr, optr unsafe.Pointer) interface{} { 505 slice := make([]uint32, len(*(*[]uint32)(sptr))) 506 copy(slice, *(*[]uint32)(sptr)) 507 for i := 0; i < len(slice); i++ { 508 found := false 509 for _, v := range *(*[]uint32)(optr) { 510 if v == slice[i] { 511 found = true 512 break 513 } 514 } 515 if !found { 516 slice = append(slice[:i], slice[i+1:]...) 517 i-- 518 } 519 } 520 return slice 521 } 522 523 func uint64Intersect(sptr, optr unsafe.Pointer) interface{} { 524 slice := make([]uint64, len(*(*[]uint64)(sptr))) 525 copy(slice, *(*[]uint64)(sptr)) 526 for i := 0; i < len(slice); i++ { 527 found := false 528 for _, v := range *(*[]uint64)(optr) { 529 if v == slice[i] { 530 found = true 531 break 532 } 533 } 534 if !found { 535 slice = append(slice[:i], slice[i+1:]...) 536 i-- 537 } 538 } 539 return slice 540 } 541 542 func float32Intersect(sptr, optr unsafe.Pointer) interface{} { 543 slice := make([]float32, len(*(*[]float32)(sptr))) 544 copy(slice, *(*[]float32)(sptr)) 545 for i := 0; i < len(slice); i++ { 546 found := false 547 for _, v := range *(*[]float32)(optr) { 548 if v == slice[i] { 549 found = true 550 break 551 } 552 } 553 if !found { 554 slice = append(slice[:i], slice[i+1:]...) 555 i-- 556 } 557 } 558 return slice 559 } 560 561 func float64Intersect(sptr, optr unsafe.Pointer) interface{} { 562 slice := make([]float64, len(*(*[]float64)(sptr))) 563 copy(slice, *(*[]float64)(sptr)) 564 for i := 0; i < len(slice); i++ { 565 found := false 566 for _, v := range *(*[]float64)(optr) { 567 if v == slice[i] { 568 found = true 569 break 570 } 571 } 572 if !found { 573 slice = append(slice[:i], slice[i+1:]...) 574 i-- 575 } 576 } 577 return slice 578 } 579 580 // Except 581 func stringExcept(sptr, optr unsafe.Pointer) interface{} { 582 s := make([]string, len(*(*[]string)(sptr))) 583 copy(s, *(*[]string)(sptr)) 584 for i := 0; i < len(s); i++ { 585 for _, v := range *(*[]string)(optr) { 586 if v == s[i] { 587 s = append(s[:i], s[i+1:]...) 588 i-- 589 break 590 } 591 } 592 } 593 return s 594 } 595 596 func intExcept(sptr, optr unsafe.Pointer) interface{} { 597 s := make([]int, len(*(*[]int)(sptr))) 598 copy(s, *(*[]int)(sptr)) 599 for i := 0; i < len(s); i++ { 600 for _, v := range *(*[]int)(optr) { 601 if v == s[i] { 602 s = append(s[:i], s[i+1:]...) 603 i-- 604 break 605 } 606 } 607 } 608 return s 609 } 610 611 func int8Except(sptr, optr unsafe.Pointer) interface{} { 612 s := make([]int8, len(*(*[]int8)(sptr))) 613 copy(s, *(*[]int8)(sptr)) 614 for i := 0; i < len(s); i++ { 615 for _, v := range *(*[]int8)(optr) { 616 if v == s[i] { 617 s = append(s[:i], s[i+1:]...) 618 i-- 619 break 620 } 621 } 622 } 623 return s 624 } 625 626 func int16Except(sptr, optr unsafe.Pointer) interface{} { 627 s := make([]int16, len(*(*[]int16)(sptr))) 628 copy(s, *(*[]int16)(sptr)) 629 for i := 0; i < len(s); i++ { 630 for _, v := range *(*[]int16)(optr) { 631 if v == s[i] { 632 s = append(s[:i], s[i+1:]...) 633 i-- 634 break 635 } 636 } 637 } 638 return s 639 } 640 641 func int32Except(sptr, optr unsafe.Pointer) interface{} { 642 s := make([]int32, len(*(*[]int32)(sptr))) 643 copy(s, *(*[]int32)(sptr)) 644 for i := 0; i < len(s); i++ { 645 for _, v := range *(*[]int32)(optr) { 646 if v == s[i] { 647 s = append(s[:i], s[i+1:]...) 648 i-- 649 break 650 } 651 } 652 } 653 return s 654 } 655 656 func int64Except(sptr, optr unsafe.Pointer) interface{} { 657 s := make([]int64, len(*(*[]int64)(sptr))) 658 copy(s, *(*[]int64)(sptr)) 659 for i := 0; i < len(s); i++ { 660 for _, v := range *(*[]int64)(optr) { 661 if v == s[i] { 662 s = append(s[:i], s[i+1:]...) 663 i-- 664 break 665 } 666 } 667 } 668 return s 669 } 670 671 func uintExcept(sptr, optr unsafe.Pointer) interface{} { 672 s := make([]uint, len(*(*[]uint)(sptr))) 673 copy(s, *(*[]uint)(sptr)) 674 for i := 0; i < len(s); i++ { 675 for _, v := range *(*[]uint)(optr) { 676 if v == s[i] { 677 s = append(s[:i], s[i+1:]...) 678 i-- 679 break 680 } 681 } 682 } 683 return s 684 } 685 686 func uint8Except(sptr, optr unsafe.Pointer) interface{} { 687 s := make([]uint8, len(*(*[]uint8)(sptr))) 688 copy(s, *(*[]uint8)(sptr)) 689 for i := 0; i < len(s); i++ { 690 for _, v := range *(*[]uint8)(optr) { 691 if v == s[i] { 692 s = append(s[:i], s[i+1:]...) 693 i-- 694 break 695 } 696 } 697 } 698 return s 699 } 700 701 func uint16Except(sptr, optr unsafe.Pointer) interface{} { 702 s := make([]uint16, len(*(*[]uint16)(sptr))) 703 copy(s, *(*[]uint16)(sptr)) 704 for i := 0; i < len(s); i++ { 705 for _, v := range *(*[]uint16)(optr) { 706 if v == s[i] { 707 s = append(s[:i], s[i+1:]...) 708 i-- 709 break 710 } 711 } 712 } 713 return s 714 } 715 716 func uint32Except(sptr, optr unsafe.Pointer) interface{} { 717 s := make([]uint32, len(*(*[]uint32)(sptr))) 718 copy(s, *(*[]uint32)(sptr)) 719 for i := 0; i < len(s); i++ { 720 for _, v := range *(*[]uint32)(optr) { 721 if v == s[i] { 722 s = append(s[:i], s[i+1:]...) 723 i-- 724 break 725 } 726 } 727 } 728 return s 729 } 730 731 func uint64Except(sptr, optr unsafe.Pointer) interface{} { 732 s := make([]uint64, len(*(*[]uint64)(sptr))) 733 copy(s, *(*[]uint64)(sptr)) 734 for i := 0; i < len(s); i++ { 735 for _, v := range *(*[]uint64)(optr) { 736 if v == s[i] { 737 s = append(s[:i], s[i+1:]...) 738 i-- 739 break 740 } 741 } 742 } 743 return s 744 } 745 746 func float32Except(sptr, optr unsafe.Pointer) interface{} { 747 s := make([]float32, len(*(*[]float32)(sptr))) 748 copy(s, *(*[]float32)(sptr)) 749 for i := 0; i < len(s); i++ { 750 for _, v := range *(*[]float32)(optr) { 751 if v == s[i] { 752 s = append(s[:i], s[i+1:]...) 753 i-- 754 break 755 } 756 } 757 } 758 return s 759 } 760 761 func float64Except(sptr, optr unsafe.Pointer) interface{} { 762 s := make([]float64, len(*(*[]float64)(sptr))) 763 copy(s, *(*[]float64)(sptr)) 764 for i := 0; i < len(s); i++ { 765 for _, v := range *(*[]float64)(optr) { 766 if v == s[i] { 767 s = append(s[:i], s[i+1:]...) 768 i-- 769 break 770 } 771 } 772 } 773 return s 774 }