# Differences

This shows you the differences between two versions of the page.

ada.containers.vectors [2012/01/24 08:00] thomaslocke [Vectors.Contains] |
ada.containers.vectors [2012/01/24 08:10] (current) thomaslocke [Equality] |
||
---|---|---|---|

Line 2208: | Line 2208: | ||

And the output is: | And the output is: | ||

- | -1 No Element! | + | <code> |

- | 9 Element! | + | -1 No Element! |

- | -1 No Element! | + | 9 Element! |

- | 8 Element! | + | -1 No Element! |

+ | 8 Element! | ||

+ | </code> | ||

I've honestly never had any use for //Has_Element// while working with vectors, but that's probably because I hardly ever use cursors with vectors. With [[Ada.Containers.Doubly_Linked_Lists]] it is a different story though, as the only means of navigating a doubly linked list is by using cursors. | I've honestly never had any use for //Has_Element// while working with vectors, but that's probably because I hardly ever use cursors with vectors. With [[Ada.Containers.Doubly_Linked_Lists]] it is a different story though, as the only means of navigating a doubly linked list is by using cursors. | ||

- | [[Vectors.Has_Element|Example Source]] | + | [[Vectors.Has_Element|Vectors.Has_Element Example Source]] |

===== From index to cursor, and vice versa ===== | ===== From index to cursor, and vice versa ===== | ||

Line 2263: | Line 2265: | ||

The important thing to take away from this example, is the //No_Element// part. If the given //Index// is out of range, then //No_Element// is returned. | The important thing to take away from this example, is the //No_Element// part. If the given //Index// is out of range, then //No_Element// is returned. | ||

- | [[Vectors.To_Cursor|Example Source]] | + | [[Vectors.To_Cursor|Vectors.To_Cursor Example Source]] |

==== Vectors.To_Index ==== | ==== Vectors.To_Index ==== | ||

Line 2296: | Line 2298: | ||

This is not exactly rocket science, but it is worth noting that //No_Element// is "transformed" into //No_Index// when //To_Index// is called on a cursor which point at //No_Element//. | This is not exactly rocket science, but it is worth noting that //No_Element// is "transformed" into //No_Index// when //To_Index// is called on a cursor which point at //No_Element//. | ||

- | [[Vectors.To_Index|Example Source]] | + | [[Vectors.To_Index|Vectors.To_Index Example Source]] |

===== Vectors.Generic_Sorting ===== | ===== Vectors.Generic_Sorting ===== | ||

Line 2357: | Line 2359: | ||

And there you have it: A perfectly sorted //quotes.txt// file. It just doesn't get any simpler than that. | And there you have it: A perfectly sorted //quotes.txt// file. It just doesn't get any simpler than that. | ||

- | [[Vectors.Generic_Sorting.Sort|Example Source]] | + | [[Vectors.Generic_Sorting.Sort|Vectors.Generic_Sorting.Sort Example Source]] |

==== Generic_Sorting.Is_Sorted ==== | ==== Generic_Sorting.Is_Sorted ==== | ||

Line 2408: | Line 2410: | ||

In case of large vectors, this is not very efficient. Given that, you should of course only use //Is_Sorted// if it's absolutely necessary. | In case of large vectors, this is not very efficient. Given that, you should of course only use //Is_Sorted// if it's absolutely necessary. | ||

- | [[Vectors.Generic_Sorting.Is_Sorted|Example Source]] | + | [[Vectors.Generic_Sorting.Is_Sorted|Vectors.Generic_Sorting.Is_Sorted Example Source]] |

==== Generic_Sorting.Merge ==== | ==== Generic_Sorting.Merge ==== | ||

Line 2482: | Line 2484: | ||

When using //Merge// it is very important to remember this: Both the //Target// and //Source// vectors **must** be sorted prior to the //Merge// call, else you'll end up with an un-sorted vector as the result. (If that is all you want, then it's probably faster to use one of the following procedures: [[Ada.Containers.Vectors#Vectors.Append | Append]], [[Ada.Containers.Vectors#Vectors.Insert | Insert]], [[Ada.Containers.Vectors#Vectors.Prepend | Prepend]]. Or you could simply use the //&// function to get the job done.) | When using //Merge// it is very important to remember this: Both the //Target// and //Source// vectors **must** be sorted prior to the //Merge// call, else you'll end up with an un-sorted vector as the result. (If that is all you want, then it's probably faster to use one of the following procedures: [[Ada.Containers.Vectors#Vectors.Append | Append]], [[Ada.Containers.Vectors#Vectors.Insert | Insert]], [[Ada.Containers.Vectors#Vectors.Prepend | Prepend]]. Or you could simply use the //&// function to get the job done.) | ||

- | [[Vectors.Generic_Sorting.Merge|Example Source]] | + | [[Vectors.Generic_Sorting.Merge|Vectors.Generic_Sorting.Merge Example Source]] |

===== Concatenate using the & operator ===== | ===== Concatenate using the & operator ===== | ||

Line 2630: | Line 2632: | ||

If you care about performance, it is probably best to avoid using the "&" functions. As the simple benchmark shows, there are faster ways to concatenate vectors and/or vector elements than using "&". | If you care about performance, it is probably best to avoid using the "&" functions. As the simple benchmark shows, there are faster ways to concatenate vectors and/or vector elements than using "&". | ||

- | [[The|& operator Example Source]] | + | [[The & operator Example Source|The & operator Example Source]] |

===== Equality ===== | ===== Equality ===== | ||

Line 2667: | Line 2669: | ||

This is of course as expected. | This is of course as expected. | ||

- | [[Equality|Example Source]] | + | [[Equality|Equality Example Source]] |