// Creating a vector of integers CUtlVectormyVector; // Adding elements to the vector myVector.Add(1); myVector.Add(2); myVector.Add(3); // Finding an element in the vector int index = myVector.Find(2); if (index == -1) { cout << "Element not found"; } else { cout << "Element found at index " << index; }
// Creating a vector of strings CUtlVectorPackage library: The CUtlVector class is part of the Source SDK, a library of tools and resources for game development using the Source engine. It can be found in the header file utlvector.h.myVector; // Adding elements to the vector myVector.Add("apple"); myVector.Add("banana"); myVector.Add("cherry"); // Finding an element in the vector int index = myVector.Find("banana"); if (index == -1) { cout << "Element not found"; } else { cout << "Element found at index " << index; }