gitlab.com/evatix-go/core@v1.3.55/coredata/corestr/newCollectionsOfCollectionPtrCreator.go (about)

     1  package corestr
     2  
     3  import "gitlab.com/evatix-go/core/constants"
     4  
     5  type newCollectionsOfCollectionPtrCreator struct{}
     6  
     7  func (it *newCollectionsOfCollectionPtrCreator) Cap(
     8  	capacity int,
     9  ) *CollectionsOfCollectionPtr {
    10  	collection := make(
    11  		[]*CollectionPtr,
    12  		constants.Zero,
    13  		capacity)
    14  
    15  	return &CollectionsOfCollectionPtr{
    16  		items: collection,
    17  	}
    18  }
    19  
    20  func (it *newCollectionsOfCollectionPtrCreator) Empty() *CollectionsOfCollectionPtr {
    21  	collection := make([]*CollectionPtr, constants.Zero)
    22  
    23  	return &CollectionsOfCollectionPtr{
    24  		items: collection,
    25  	}
    26  }
    27  
    28  func (it *newCollectionsOfCollectionPtrCreator) StringsOfStringsPointer(
    29  	stringItems ...*[]string,
    30  ) *CollectionsOfCollectionPtr {
    31  	length := LengthOfStringsOfPointerStrings(
    32  		&stringItems)
    33  
    34  	return it.LenCap(
    35  		constants.Zero,
    36  		length,
    37  	).AddsStringsOfPointerStrings(
    38  		constants.Zero,
    39  		&stringItems)
    40  }
    41  
    42  func (it *newCollectionsOfCollectionPtrCreator) StringsOfPointerStrings(
    43  	stringItems *[]*[]string,
    44  ) *CollectionsOfCollectionPtr {
    45  	length := LengthOfStringsOfPointerStrings(
    46  		stringItems)
    47  
    48  	return it.LenCap(
    49  		constants.Zero,
    50  		length,
    51  	).AddsStringsOfPointerStrings(
    52  		constants.Zero,
    53  		stringItems)
    54  }
    55  
    56  func (it *newCollectionsOfCollectionPtrCreator) Strings(
    57  	stringItems []string,
    58  ) *CollectionsOfCollectionPtr {
    59  	length := len(stringItems)
    60  
    61  	return it.LenCap(
    62  		constants.Zero,
    63  		length,
    64  	).AddStringsPtr(constants.Zero, &stringItems)
    65  }
    66  
    67  func (it *newCollectionsOfCollectionPtrCreator) StringsPtr(
    68  	stringItems *[]string,
    69  ) *CollectionsOfCollectionPtr {
    70  	length := LengthOfStringsPtr(stringItems)
    71  
    72  	return it.LenCap(
    73  		constants.Zero,
    74  		length,
    75  	).AddStringsPtr(constants.Zero, stringItems)
    76  }
    77  
    78  func (it *newCollectionsOfCollectionPtrCreator) CapStrings(
    79  	addCapacity int,
    80  	stringItems ...string,
    81  ) *CollectionsOfCollectionPtr {
    82  	length := len(
    83  		stringItems)
    84  
    85  	if length == 0 && addCapacity == 0 {
    86  		return it.Empty()
    87  	}
    88  
    89  	if length == 0 && addCapacity > 0 {
    90  		return it.Cap(length)
    91  	}
    92  
    93  	collection := it.Cap(
    94  		length + addCapacity)
    95  
    96  	return collection.AddStringsPtr(
    97  		constants.Zero,
    98  		&stringItems,
    99  	)
   100  }
   101  
   102  func (it *newCollectionsOfCollectionPtrCreator) CapStringsPtr(
   103  	addCapacity int,
   104  	stringItems *[]string,
   105  ) *CollectionsOfCollectionPtr {
   106  	length := LengthOfStringsPtr(
   107  		stringItems)
   108  
   109  	if length == 0 && addCapacity == 0 {
   110  		return it.Empty()
   111  	}
   112  
   113  	if length == 0 && addCapacity > 0 {
   114  		return it.Cap(length)
   115  	}
   116  
   117  	collection := it.Cap(
   118  		length + addCapacity)
   119  
   120  	return collection.AddStringsPtr(
   121  		constants.Zero,
   122  		stringItems,
   123  	)
   124  }
   125  
   126  func (it *newCollectionsOfCollectionPtrCreator) PointerStrings(
   127  	stringItems []*string,
   128  ) *CollectionsOfCollectionPtr {
   129  	return it.CapPointerStrings(
   130  		0,
   131  		stringItems...)
   132  }
   133  
   134  func (it *newCollectionsOfCollectionPtrCreator) CapPointerStrings(
   135  	capacity int,
   136  	stringItems ...*string,
   137  ) *CollectionsOfCollectionPtr {
   138  	length := len(stringItems)
   139  
   140  	if length == 0 && capacity == 0 {
   141  		return it.Empty()
   142  	}
   143  
   144  	if length == 0 && capacity > 0 {
   145  		return it.Cap(length)
   146  	}
   147  
   148  	collection := it.Cap(
   149  		length + capacity)
   150  
   151  	return collection.AddPointerStrings(
   152  		stringItems...)
   153  }
   154  
   155  func (it *newCollectionsOfCollectionPtrCreator) LenCap(
   156  	length,
   157  	capacity int,
   158  ) *CollectionsOfCollectionPtr {
   159  	collection := make(
   160  		[]*CollectionPtr,
   161  		length,
   162  		capacity)
   163  
   164  	return &CollectionsOfCollectionPtr{
   165  		items: collection,
   166  	}
   167  }