Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template<class ItemType>
- ArrayBag Intersection(const ArrayBag& bag2)
- {
- ArrayBag<ItemType> ReturnBag;
- <ItemType> TempArray[this.maxItems];
- int i, j;
- for (i = 0, i < this.maxItems + 1, i++)
- {
- TempArray[i] = NULL;
- }
- for (i = 0, i<this.maxItems + 1, i++)
- {
- for (j = 0, j < this.Maxitems + 1, j++)
- {
- if (this.items[i] == bag2.items[j])
- {
- TempArray[i] = this.items[i];
- }
- }
- }
- j = 0;
- for (i = 0, i < this.maxItems + 1, i++)
- {
- if (TempArray[i] != NULL)
- {
- ReturnBag.items[j] = TempArray[i];
- j++;
- }
- }
- return ReturnBag;
- }
- template<class ItemType>
- ArrayBag Difference(const ArrayBag& bag2)
- {
- ArrayBag<ItemType> ReturnBag;
- <ItemType> TempArray[this.maxItems];
- int i, j;
- for (i = 0, i < this.maxItems + 1, i++)
- {
- TempArray[i] = NULL;
- }
- for (i = 0, i<this.maxItems + 1, i++)
- {
- for (j = 0, j < this.maxItems + 1, j++)
- {
- if (this.items[i] != bag2.items[j])
- {
- TempArray[i] = this.items[i];
- }
- }
- }
- j = 0;
- for (i = 0, i > this.maxItems + 1, i++)
- {
- if (TempArray[i] != NULL)
- {
- ReturnBag.items[j] = TempArray[i];
- j++;
- }
- }
- return ReturnBag;
- }
- template<class ItemType>
- ArrayBag Union(const ArrayBag& bag2)
- {
- ArrayBag<ItemType> ReturnBag;
- if ((this.itemCount + bag2.itemCount) > this.maxItems)
- {
- return ReturnBag;
- }
- <ItemType> TempArray[this.maxItems];
- int i(0), j(0);
- for (i = 0, i < this.maxitems + 1, i++)
- {
- TempArray[i] = NULL;
- }
- for (i = 0, i<this.maxItems + 1, i++)
- {
- TempArray[j] = this.items[i];
- j++;
- tempArray[j] = bag2.items[i];
- j++;
- }
- j = 0;
- for (i = 0, i < this.maxItems + 1, i++)
- {
- if (TempArray[i] != NULL)
- {
- ReturnBag.items[j] = TempArray[i];
- j++;
- }
- }
- return ReturnBag;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement